chore: fix flake in TestResponsesInjectedTool (#25630)

Fixes flake in TestResponsesInjectedTool.
See
https://github.com/coder/coder/pull/25630/changes/d9bfeb20092129127ad5e7958c5b8dbf46740527
for reproduction.
Due to AsyncRecorded token usages may be recorded in different order
then expected.

Fixes: https://github.com/coder/internal/issues/1544
This commit is contained in:
Paweł Banaszewski
2026-05-25 16:41:55 +02:00
committed by GitHub
parent 4ddda3a9db
commit 1a8a153c56
@@ -920,7 +920,12 @@ func TestResponsesInjectedTool(t *testing.T) {
for i := range tokenUsages {
tokenUsages[i].InterceptionID = "" // ignore interception ID and time creation when comparing
tokenUsages[i].CreatedAt = time.Time{}
require.Equal(t, tc.expectTokenUsages[i], *tokenUsages[i])
}
// Match by content, not position, AsyncRecorder may flake.
// See https://github.com/coder/internal/issues/1544.
for _, expected := range tc.expectTokenUsages {
require.Contains(t, tokenUsages, &expected)
}
// Verify the response is the final tool response (after agentic loop).