Skip to content

refactor: generate application URL on backend side #9618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
mtojek committed Sep 12, 2023
commit 74d9dbe3e37a1e1ff676d26ca576b287fc929812
16 changes: 14 additions & 2 deletions coderd/workspaceapps/apptest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,13 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
workspaceBuild := coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)

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

appURL := httpapi.ApplicationURL{
AppSlugOrPort: protoApps[i].Slug,
// findProtoApp is needed as the order of apps returned from PG database
// is not guaranteed.
AppSlugOrPort: findProtoApp(t, protoApps, app.Slug).Slug,
AgentName: proxyTestAgentName,
WorkspaceName: workspace.Name,
Username: me.Username,
Expand Down Expand Up @@ -406,6 +408,16 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
return workspace, agents[0]
}

func findProtoApp(t *testing.T, protoApps []*proto.App, slug string) proto.App {
for _, protoApp := range protoApps {
if protoApp.Slug == slug {
return *protoApp
}
}
require.FailNowf(t, "proto app not found (slug: %q)", slug)
return proto.App{}
}

func doWithRetries(t require.TestingT, client *codersdk.Client, req *http.Request) (*http.Response, error) {
var resp *http.Response
var err error
Expand Down