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

Function TestSubAgent_CloneConfig

agent/agentcontainers/subagent_test.go:310–358  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

308}
309
310func TestSubAgent_CloneConfig(t *testing.T) {
311 t.Parallel()
312
313 t.Run("CopiesIDFromDevcontainer", func(t *testing.T) {
314 t.Parallel()
315
316 subAgent := agentcontainers.SubAgent{
317 ID: uuid.New(),
318 Name: "original-name",
319 Directory: "/workspace",
320 Architecture: "amd64",
321 OperatingSystem: "linux",
322 DisplayApps: []codersdk.DisplayApp{codersdk.DisplayAppVSCodeDesktop},
323 Apps: []agentcontainers.SubAgentApp{{Slug: "app1"}},
324 }
325 expectedID := uuid.MustParse("550e8400-e29b-41d4-a716-446655440000")
326 dc := codersdk.WorkspaceAgentDevcontainer{
327 Name: "devcontainer-name",
328 SubagentID: uuid.NullUUID{UUID: expectedID, Valid: true},
329 }
330
331 cloned := subAgent.CloneConfig(dc)
332
333 assert.Equal(t, expectedID, cloned.ID)
334 assert.Equal(t, dc.Name, cloned.Name)
335 assert.Equal(t, subAgent.Directory, cloned.Directory)
336 assert.Zero(t, cloned.AuthToken, "AuthToken should not be copied")
337 })
338
339 t.Run("HandlesNilSubagentID", func(t *testing.T) {
340 t.Parallel()
341
342 subAgent := agentcontainers.SubAgent{
343 ID: uuid.New(),
344 Name: "original-name",
345 Directory: "/workspace",
346 Architecture: "amd64",
347 OperatingSystem: "linux",
348 }
349 dc := codersdk.WorkspaceAgentDevcontainer{
350 Name: "devcontainer-name",
351 SubagentID: uuid.NullUUID{Valid: false},
352 }
353
354 cloned := subAgent.CloneConfig(dc)
355
356 assert.Equal(t, uuid.Nil, cloned.ID)
357 })
358}
359
360func TestSubAgent_EqualConfig(t *testing.T) {
361 t.Parallel()

Callers

nothing calls this directly

Calls 4

CloneConfigMethod · 0.95
RunMethod · 0.65
NewMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected