MCPcopy Create free account
hub / github.com/coder/coder / awaitTools

Function awaitTools

agent/x/agentmcp/configwatcher_internal_test.go:37–45  ·  view source on GitHub ↗

These tests exercise the dual-agent late-file regression: the inner sandbox agent settles startup quickly and calls Reload while `~/.mcp.json` still does not exist on disk. The host agent then writes the file ~20s later. Before this fix, the manager cached an empty snapshot and stayed empty until a

(ctx context.Context, t *testing.T, m *Manager, pred func([]workspacesdk.MCPToolInfo) bool)

Source from the content-addressed store, hash-verified

35// awaitTools polls cachedTools until the predicate succeeds or
36// the context expires. It avoids time.Sleep loops in callers.
37func awaitTools(ctx context.Context, t *testing.T, m *Manager, pred func([]workspacesdk.MCPToolInfo) bool) []workspacesdk.MCPToolInfo {
38 t.Helper()
39 var final []workspacesdk.MCPToolInfo
40 testutil.Eventually(ctx, t, func(context.Context) bool {
41 final = m.cachedTools()
42 return pred(final)
43 }, testutil.IntervalFast)
44 return final
45}
46
47// useFastDebounce shortens the watcher's debounce window so
48// real-clock tests do not stall on the 250 ms default. Must be

Calls 3

EventuallyFunction · 0.92
cachedToolsMethod · 0.80
HelperMethod · 0.65

Tested by

no test coverage detected