(t *testing.T)
| 61 | } |
| 62 | |
| 63 | func 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 | |
| 93 | func TestClassifyCoordinatorRPCExit(t *testing.T) { |
| 94 | t.Parallel() |
nothing calls this directly
no test coverage detected