Skip to content

Commit 74d9dbe

Browse files
committed
fix
1 parent fdc1845 commit 74d9dbe

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

coderd/workspaceapps/apptest/setup.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,13 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
350350
workspaceBuild := coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
351351

352352
// Verify app subdomains
353-
for i, app := range workspaceBuild.Resources[0].Agents[0].Apps {
353+
for _, app := range workspaceBuild.Resources[0].Agents[0].Apps {
354354
require.True(t, app.Subdomain)
355355

356356
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,
358360
AgentName: proxyTestAgentName,
359361
WorkspaceName: workspace.Name,
360362
Username: me.Username,
@@ -406,6 +408,16 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
406408
return workspace, agents[0]
407409
}
408410

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+
409421
func doWithRetries(t require.TestingT, client *codersdk.Client, req *http.Request) (*http.Response, error) {
410422
var resp *http.Response
411423
var err error

0 commit comments

Comments
 (0)