@@ -350,11 +350,13 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
350
350
workspaceBuild := coderdtest .AwaitWorkspaceBuildJob (t , client , workspace .LatestBuild .ID )
351
351
352
352
// Verify app subdomains
353
- for i , app := range workspaceBuild .Resources [0 ].Agents [0 ].Apps {
353
+ for _ , app := range workspaceBuild .Resources [0 ].Agents [0 ].Apps {
354
354
require .True (t , app .Subdomain )
355
355
356
356
appURL := httpapi.ApplicationURL {
357
- AppSlugOrPort : protoApps [i ].Slug ,
357
+ // findProtoApp is needed as the order of apps returned from PG database
358
+ // is not guaranteed.
359
+ AppSlugOrPort : findProtoApp (t , protoApps , app .Slug ).Slug ,
358
360
AgentName : proxyTestAgentName ,
359
361
WorkspaceName : workspace .Name ,
360
362
Username : me .Username ,
@@ -406,6 +408,16 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
406
408
return workspace , agents [0 ]
407
409
}
408
410
411
+ func findProtoApp (t * testing.T , protoApps []* proto.App , slug string ) proto.App {
412
+ for _ , protoApp := range protoApps {
413
+ if protoApp .Slug == slug {
414
+ return * protoApp
415
+ }
416
+ }
417
+ require .FailNowf (t , "proto app not found (slug: %q)" , slug )
418
+ return proto.App {}
419
+ }
420
+
409
421
func doWithRetries (t require.TestingT , client * codersdk.Client , req * http.Request ) (* http.Response , error ) {
410
422
var resp * http.Response
411
423
var err error
0 commit comments