RequireWorkspaceAgentByName avoids weak nil UUID assertions when a fixture requires a specific agent.
(t testing.TB, resources []codersdk.WorkspaceResource, name string)
| 1280 | |
| 1281 | // RequireWorkspaceAgentByName avoids weak nil UUID assertions when a fixture requires a specific agent. |
| 1282 | func 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. |