MCPcopy Index your code
hub / github.com/coder/coder / TestRun

Function TestRun

support/support_test.go:38–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestRun(t *testing.T) {
39 t.Parallel()
40
41 t.Run("OK", func(t *testing.T) {
42 t.Parallel()
43 cfg := coderdtest.DeploymentValues(t)
44 promPort := testutil.RandomPort(t)
45 cfg.Prometheus.Enable = serpent.Bool(true)
46 cfg.Prometheus.Address.Host = "127.0.0.1"
47 cfg.Prometheus.Address.Port = fmt.Sprintf("%d", promPort)
48 cfg.Experiments = []string{"foo"}
49 ctx := testutil.Context(t, testutil.WaitLong)
50 client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{
51 DeploymentValues: cfg,
52 Logger: ptr.Ref(slog.Make(sloghuman.Sink(io.Discard))),
53 })
54 admin := coderdtest.CreateFirstUser(t, client)
55 ws, agt := setupWorkspaceAndAgent(ctx, t, client, db, admin)
56
57 bun, err := support.Run(ctx, &support.Deps{
58 Client: client,
59 Log: testutil.Logger(t).Named("bundle"),
60 WorkspaceID: ws.ID,
61 AgentID: agt.ID,
62 })
63 require.NoError(t, err)
64 assertNotNilNotEmpty(t, bun, "bundle should be present")
65 assertNotNilNotEmpty(t, bun.Deployment.BuildInfo, "deployment build info should be present")
66 assertNotNilNotEmpty(t, bun.Deployment.Config, "deployment config should be present")
67 assertNotNilNotEmpty(t, bun.Deployment.Config.Options, "deployment config should be present")
68 assertSanitizedDeploymentConfig(t, bun.Deployment.Config)
69 assertNotNilNotEmpty(t, bun.Deployment.HealthReport, "deployment health report should be present")
70 assertNotNilNotEmpty(t, bun.Deployment.Experiments, "deployment experiments should be present")
71 require.NotNil(t, bun.Deployment.Licenses, "license status should be present")
72 assertNotNilNotEmpty(t, bun.Network.ConnectionInfo, "agent connection info should be present")
73 assertNotNilNotEmpty(t, bun.Network.CoordinatorDebug, "network coordinator debug should be present")
74 assertNotNilNotEmpty(t, bun.Network.Netcheck, "network netcheck should be present")
75 assertNotNilNotEmpty(t, bun.Network.TailnetDebug, "network tailnet debug should be present")
76 assertNotNilNotEmpty(t, bun.Network.Interfaces, "network interfaces health should be present")
77 assertNotNilNotEmpty(t, bun.Workspace.Workspace, "workspace should be present")
78 assertSanitizedWorkspace(t, bun.Workspace.Workspace)
79 assertNotNilNotEmpty(t, bun.Workspace.BuildLogs, "workspace build logs should be present")
80 assertNotNilNotEmpty(t, bun.Workspace.Template, "workspace template should be present")
81 assertNotNilNotEmpty(t, bun.Workspace.TemplateVersion, "workspace template version should be present")
82 assertNotNilNotEmpty(t, bun.Workspace.TemplateFileBase64, "workspace template file should be present")
83 require.NotNil(t, bun.Workspace.Parameters, "workspace parameters should be present")
84 assertNotNilNotEmpty(t, bun.Agent.Agent, "agent should be present")
85 assertSanitizedEnv(t, bun.Agent.Agent.EnvironmentVariables)
86 assertNotNilNotEmpty(t, bun.Agent.ListeningPorts, "agent listening ports should be present")
87 assertNotNilNotEmpty(t, bun.Agent.Logs, "agent logs should be present")
88 assertNotNilNotEmpty(t, bun.Agent.Manifest, "agent manifest should be present")
89 assertSanitizedEnv(t, bun.Agent.Manifest.EnvironmentVariables)
90 assertNotNilNotEmpty(t, bun.Agent.AgentMagicsockHTML, "agent magicsock should be present")
91 assertNotNilNotEmpty(t, bun.Agent.ClientMagicsockHTML, "client magicsock should be present")
92 assertNotNilNotEmpty(t, bun.Agent.PeerDiagnostics, "agent peer diagnostics should be present")
93 assertNotNilNotEmpty(t, bun.Agent.PingResult, "agent ping result should be present")
94 assertNotNilNotEmpty(t, bun.Agent.Prometheus, "agent prometheus metrics should be present")
95 assertNotNilNotEmpty(t, bun.Deployment.Prometheus, "deployment prometheus metrics should be present")

Callers

nothing calls this directly

Calls 15

StatusCodeMethod · 0.95
DeploymentValuesFunction · 0.92
RandomPortFunction · 0.92
ContextFunction · 0.92
NewWithDatabaseFunction · 0.92
RefFunction · 0.92
CreateFirstUserFunction · 0.92
RunFunction · 0.92
LoggerFunction · 0.92
NewFunction · 0.92
CreateAnotherUserFunction · 0.92
setupWorkspaceAndAgentFunction · 0.85

Tested by

no test coverage detected