Files
coder/coderd/x/chatd/testhooks.go
T
Hugo Dutka 658a04d28f pr 3
2026-06-04 18:51:22 +00:00

21 lines
583 B
Go

package chatd
import (
"context"
"time"
)
// 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()
if server.chatWorker == nil {
return
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
_ = server.chatWorker.WaitIdle(ctx)
}