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

Function TestContextConfigAPI_InitOnce

agent/agent_internal_test.go:63–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestContextConfigAPI_InitOnce(t *testing.T) {
64 t.Parallel()
65
66 // After the fix, contextConfigAPI is set once in init() and
67 // never reassigned. Resolve() evaluates lazily via the
68 // manifest, so there is no concurrent write to race with.
69 dir1 := platformAbsPath("dir1")
70 dir2 := platformAbsPath("dir2")
71
72 a := &agent{}
73 a.manifest.Store(&agentsdk.Manifest{Directory: dir1})
74 a.contextConfigAPI = agentcontextconfig.NewAPI(func() string {
75 if m := a.manifest.Load(); m != nil {
76 return m.Directory
77 }
78 return ""
79 }, agentcontextconfig.Config{})
80
81 mcpFiles1 := a.contextConfigAPI.MCPConfigFiles()
82 require.NotEmpty(t, mcpFiles1)
83 require.Contains(t, mcpFiles1[0], dir1)
84
85 // Simulate manifest update on reconnection -- no field
86 // reassignment needed, the lazy closure picks it up.
87 a.manifest.Store(&agentsdk.Manifest{Directory: dir2})
88 mcpFiles2 := a.contextConfigAPI.MCPConfigFiles()
89 require.NotEmpty(t, mcpFiles2)
90 require.Contains(t, mcpFiles2[0], dir2)
91}
92
93func TestClassifyCoordinatorRPCExit(t *testing.T) {
94 t.Parallel()

Callers

nothing calls this directly

Calls 7

NewAPIFunction · 0.92
MCPConfigFilesMethod · 0.80
NotEmptyMethod · 0.80
platformAbsPathFunction · 0.70
StoreMethod · 0.45
LoadMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected