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

Function TestReload_FirstBootPath

agent/x/agentmcp/reload_internal_test.go:618–643  ·  view source on GitHub ↗

TestReload_FirstBootPath verifies that the first-boot call site (agent.go) can be routed through Reload without behavioral change.

(t *testing.T)

Source from the content-addressed store, hash-verified

616// TestReload_FirstBootPath verifies that the first-boot call site
617// (agent.go) can be routed through Reload without behavioral change.
618func TestReload_FirstBootPath(t *testing.T) {
619 t.Parallel()
620
621 if os.Getenv("TEST_MCP_FAKE_SERVER") == "1" {
622 runFakeMCPServer()
623 return
624 }
625
626 ctx := testutil.Context(t, testutil.WaitLong)
627 logger := slogtest.Make(t, nil).Leveled(slog.LevelDebug)
628 dir := t.TempDir()
629
630 _, entry := fakeMCPServerConfig(t, "srv")
631 configPath := writeMCPConfig(t, dir, map[string]mcpServerEntry{"srv": entry})
632
633 m := NewManager(ctx, logger, agentexec.DefaultExecer, nil)
634 t.Cleanup(func() { _ = m.Close() })
635
636 // Simulate first-boot: Reload with the initial config.
637 err := m.Reload(ctx, []string{configPath})
638 require.NoError(t, err)
639
640 tools := m.cachedTools()
641 require.Len(t, tools, 1)
642 assert.Contains(t, tools[0].Name, "echo")
643}
644
645// TestReload_NoopWhenUnchanged verifies that Reload returns
646// immediately without reconnecting when the snapshot is fresh.

Callers

nothing calls this directly

Calls 12

CloseMethod · 0.95
ReloadMethod · 0.95
cachedToolsMethod · 0.95
ContextFunction · 0.92
runFakeMCPServerFunction · 0.85
fakeMCPServerConfigFunction · 0.85
writeMCPConfigFunction · 0.85
NewManagerFunction · 0.70
TempDirMethod · 0.65
CleanupMethod · 0.65
LenMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected