mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: prevent expired contexts in chatd parallel subtests (#25107)
Parallel subtests in `coderd/x/chatd` reused a parent test context with a `testutil.WaitLong` deadline, so the context could expire before a subtest was scheduled under load. That made the subagent lifecycle tools return plain-text context errors instead of the expected JSON payload, causing flaky JSON unmarshal failures. Create fresh `chatdTestContext` values inside the affected parallel subtests and add `chatdTestContext` to the `paralleltestctx` custom function list so this pattern is caught by `make lint`. Closes https://github.com/coder/internal/issues/1494
This commit is contained in:
@@ -1510,6 +1510,7 @@ func TestResolveExploreToolSnapshot(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := chatdTestContext(t)
|
||||
gotMCPServerIDs, err := server.resolveExploreToolSnapshot(
|
||||
ctx,
|
||||
tt.parent,
|
||||
@@ -2076,6 +2077,7 @@ func TestSpawnAgent_BlankTypeReturnsValidOptions(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := chatdTestContext(t)
|
||||
resp := runSpawnAgentTool(ctx, t, server, parentChat, spawnAgentArgs{
|
||||
Type: tt.subagentType,
|
||||
Prompt: "delegate work",
|
||||
@@ -2294,6 +2296,7 @@ func TestSubagentLifecycleToolErrorsIncludePersistedSubagentType(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := chatdTestContext(t)
|
||||
result := requireToolResponseMap(t, runSubagentTool(
|
||||
ctx,
|
||||
t,
|
||||
|
||||
Reference in New Issue
Block a user