MCPcopy Index your code
hub / github.com/docker/docker-agent / TestResolveSources_DefaultAliasOverride

Function TestResolveSources_DefaultAliasOverride

pkg/config/resolve_test.go:410–441  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

408}
409
410func TestResolveSources_DefaultAliasOverride(t *testing.T) {
411 home := t.TempDir()
412 t.Setenv("HOME", home)
413
414 // Create an agent file
415 agentFile := filepath.Join(t.TempDir(), "custom-agent.yaml")
416 require.NoError(t, os.WriteFile(agentFile, []byte(`agents:
417 root:
418 model: openai/gpt-4o
419 description: Custom agent for sources
420`), 0o644))
421
422 // Set up alias for "default"
423 cfg, err := userconfig.Load()
424 require.NoError(t, err)
425 require.NoError(t, cfg.SetAlias("default", &userconfig.Alias{Path: agentFile}))
426 require.NoError(t, cfg.Save())
427
428 // ResolveSources with "default" should return the aliased file
429 sources, err := ResolveSources("default", nil)
430 require.NoError(t, err)
431 require.Len(t, sources, 1)
432
433 // The key should be the filename without extension
434 source, ok := sources["custom-agent"]
435 require.True(t, ok, "expected source key 'custom-agent', got keys: %v", sources)
436
437 // Verify it reads the custom content
438 data, err := source.Read(t.Context())
439 require.NoError(t, err)
440 assert.Contains(t, string(data), "Custom agent for sources")
441}
442
443func TestResolveSources_EmptyWithDefaultAliasOverride(t *testing.T) {
444 home := t.TempDir()

Callers

nothing calls this directly

Calls 7

LoadFunction · 0.92
ResolveSourcesFunction · 0.85
SetAliasMethod · 0.80
SaveMethod · 0.80
ContextMethod · 0.80
LenMethod · 0.65
ReadMethod · 0.65

Tested by

no test coverage detected