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

Function RequireWorkspaceAgentByName

coderd/coderdtest/coderdtest.go:1282–1295  ·  view source on GitHub ↗

RequireWorkspaceAgentByName avoids weak nil UUID assertions when a fixture requires a specific agent.

(t testing.TB, resources []codersdk.WorkspaceResource, name string)

Source from the content-addressed store, hash-verified

1280
1281// RequireWorkspaceAgentByName avoids weak nil UUID assertions when a fixture requires a specific agent.
1282func RequireWorkspaceAgentByName(t testing.TB, resources []codersdk.WorkspaceResource, name string) codersdk.WorkspaceAgent {
1283 t.Helper()
1284
1285 for _, resource := range resources {
1286 for _, agent := range resource.Agents {
1287 if agent.Name == name {
1288 return agent
1289 }
1290 }
1291 }
1292
1293 require.FailNowf(t, "workspace agent not found", "workspace agent %q not found in resources", name)
1294 return codersdk.WorkspaceAgent{}
1295}
1296
1297// AgentNames instructs the waiter to wait for the given, named agents to be connected and will
1298// return even if other agents are not connected.

Callers 2

Test_ResolveRequestFunction · 0.92

Calls 1

HelperMethod · 0.65

Tested by 2

Test_ResolveRequestFunction · 0.74