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

Function TestManager_WaitReloadTimeout

agent/x/agentmcp/manager_internal_test.go:253–280  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

251}
252
253func TestManager_WaitReloadTimeout(t *testing.T) {
254 t.Parallel()
255
256 ctx := testutil.Context(t, testutil.WaitLong)
257 logger := slogtest.Make(t, nil).Leveled(slog.LevelDebug)
258 clock := quartz.NewMock(t)
259 timerTrap := clock.Trap().NewTimer("agentmcp", "tools_reload")
260 defer timerTrap.Close()
261
262 m := NewManager(ctx, logger, agentexec.DefaultExecer, nil)
263 m.clock = clock
264 t.Cleanup(func() { _ = m.Close() })
265
266 done := make(chan error, 1)
267 go func() {
268 done <- m.waitReload(ctx, make(chan reloadResult), time.Minute)
269 }()
270
271 call := timerTrap.MustWait(ctx)
272 require.Equal(t, time.Minute, call.Duration)
273 call.MustRelease(ctx)
274
275 clock.Advance(time.Minute).MustWait(ctx)
276 err := testutil.RequireReceive(ctx, t, done)
277 require.Error(t, err)
278 assert.ErrorIs(t, err, context.DeadlineExceeded)
279 assert.Contains(t, err.Error(), "tools reload timed out after 1m0s")
280}
281
282func TestManager_ToolsStartupGate(t *testing.T) {
283 t.Parallel()

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
waitReloadMethod · 0.95
ContextFunction · 0.92
RequireReceiveFunction · 0.92
NewManagerFunction · 0.70
CloseMethod · 0.65
CleanupMethod · 0.65
EqualMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected