Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 41459dd

Browse files
committed
test
1 parent d998238 commit 41459dd

File tree

1 file changed

+46
-28
lines changed

1 file changed

+46
-28
lines changed

coderd/workspaceapps/apptest/setup.go

+46-28
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,37 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
291291
}
292292

293293
appURL := fmt.Sprintf("%s://127.0.0.1:%d?%s", scheme, port, proxyTestAppQuery)
294+
protoApps := []*proto.App{
295+
{
296+
Slug: proxyTestAppNameFake,
297+
DisplayName: proxyTestAppNameFake,
298+
SharingLevel: proto.AppSharingLevel_OWNER,
299+
// Hopefully this IP and port doesn't exist.
300+
Url: "http://127.1.0.1:65535",
301+
Subdomain: true,
302+
},
303+
{
304+
Slug: proxyTestAppNameOwner,
305+
DisplayName: proxyTestAppNameOwner,
306+
SharingLevel: proto.AppSharingLevel_OWNER,
307+
Url: appURL,
308+
Subdomain: true,
309+
},
310+
{
311+
Slug: proxyTestAppNameAuthenticated,
312+
DisplayName: proxyTestAppNameAuthenticated,
313+
SharingLevel: proto.AppSharingLevel_AUTHENTICATED,
314+
Url: appURL,
315+
Subdomain: true,
316+
},
317+
{
318+
Slug: proxyTestAppNamePublic,
319+
DisplayName: proxyTestAppNamePublic,
320+
SharingLevel: proto.AppSharingLevel_PUBLIC,
321+
Url: appURL,
322+
Subdomain: true,
323+
},
324+
}
294325
version := coderdtest.CreateTemplateVersion(t, client, orgID, &echo.Responses{
295326
Parse: echo.ParseComplete,
296327
ProvisionPlan: echo.PlanComplete,
@@ -306,33 +337,7 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
306337
Auth: &proto.Agent_Token{
307338
Token: authToken,
308339
},
309-
Apps: []*proto.App{
310-
{
311-
Slug: proxyTestAppNameFake,
312-
DisplayName: proxyTestAppNameFake,
313-
SharingLevel: proto.AppSharingLevel_OWNER,
314-
// Hopefully this IP and port doesn't exist.
315-
Url: "http://127.1.0.1:65535",
316-
},
317-
{
318-
Slug: proxyTestAppNameOwner,
319-
DisplayName: proxyTestAppNameOwner,
320-
SharingLevel: proto.AppSharingLevel_OWNER,
321-
Url: appURL,
322-
},
323-
{
324-
Slug: proxyTestAppNameAuthenticated,
325-
DisplayName: proxyTestAppNameAuthenticated,
326-
SharingLevel: proto.AppSharingLevel_AUTHENTICATED,
327-
Url: appURL,
328-
},
329-
{
330-
Slug: proxyTestAppNamePublic,
331-
DisplayName: proxyTestAppNamePublic,
332-
SharingLevel: proto.AppSharingLevel_PUBLIC,
333-
Url: appURL,
334-
},
335-
},
340+
Apps: protoApps,
336341
}},
337342
}},
338343
},
@@ -342,7 +347,20 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
342347
template := coderdtest.CreateTemplate(t, client, orgID, version.ID)
343348
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
344349
workspace := coderdtest.CreateWorkspace(t, client, orgID, template.ID, workspaceMutators...)
345-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
350+
workspaceBuild := coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
351+
352+
// Verify app subdomains
353+
for i, app := range workspaceBuild.Resources[0].Agents[0].Apps {
354+
require.True(t, app.Subdomain)
355+
356+
appURL := httpapi.ApplicationURL{
357+
AppSlugOrPort: protoApps[i].Slug,
358+
AgentName: proxyTestAgentName,
359+
WorkspaceName: workspace.Name,
360+
Username: me.Username,
361+
}
362+
require.Equal(t, appURL.String(), app.SubdomainName)
363+
}
346364

347365
agentClient := agentsdk.New(client.URL)
348366
agentClient.SetSessionToken(authToken)

0 commit comments

Comments
 (0)