mirror of
https://github.com/coder/coder.git
synced 2026-06-03 21:18:24 +00:00
4e08543ace
Chat tests previously constructed a real `openai` provider with a fake API key and no `BaseURL`, so background title generation hit `api.openai.com` and timed out under `-race`. The same root cause produced several distinct flakes: title regeneration races with synchronous `UpdateChat`/`ProposeChatTitle`, and pagination races against `updated_at` bumps from real-network processing. This moves the fake OpenAI-compatible provider and the chat-settle wait into first-class `coderdtest` capabilities. `coderd.Options.ChatProviderAPIKeys` is the new seam tests use to redirect chat traffic to a local `httptest.Server`. `coderdtest.WaitForChatSettled` replaces per-test waiters and drains tracked chat-daemon work after the chat row leaves `pending`/`running`. The `newChatClient*` constructors funnel through one options builder that installs the fake provider before the coderd test server so cleanup ordering is deterministic. Closes https://github.com/coder/internal/issues/1528 & Closes ENG-2659 Closes https://github.com/coder/internal/issues/1480 & Closes CODAGT-359 Closes https://github.com/coder/internal/issues/1507 & Closes CODAGT-368 Relates to https://github.com/coder/internal/issues/1397 & Relates to CODAGT-374
10 lines
382 B
Go
10 lines
382 B
Go
package chatd
|
|
|
|
// WaitUntilIdleForTest waits for background chat work tracked by the server to
|
|
// finish without shutting the server down. Tests use this to assert final
|
|
// database state only after asynchronous chat processing has completed.
|
|
// Close waits for the same tracked work, but also stops the server.
|
|
func WaitUntilIdleForTest(server *Server) {
|
|
server.drainInflight()
|
|
}
|