summaryrefslogtreecommitdiff
path: root/internal/api/websocket_test.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-10 23:58:00 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-10 23:58:00 +0000
commit1aea271363884f7d616d95971fd25b6c4d87de85 (patch)
treeb17e1614c3bea0e0d8e796e6df2ac608dea7d1ed /internal/api/websocket_test.go
parentce185cd10839879e566d0dcf4a14466f0148634f (diff)
test: sandbox coverage + fix WebSocket races
executor: add 7 tests for sandboxCloneSource, setupSandbox, and teardownSandbox (uncommitted-changes error, clean-no-commits removal). api: fix two data races in WebSocket tests — wsPingInterval/Deadline are now captured as locals before goroutine start; maxWsClients is moved from a package-level var into Hub.maxClients (with SetMaxClients method) so concurrent tests don't stomp each other. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/api/websocket_test.go')
-rw-r--r--internal/api/websocket_test.go5
1 files changed, 1 insertions, 4 deletions
diff --git a/internal/api/websocket_test.go b/internal/api/websocket_test.go
index 72b83f2..682a555 100644
--- a/internal/api/websocket_test.go
+++ b/internal/api/websocket_test.go
@@ -99,11 +99,8 @@ func TestWebSocket_NoTokenConfigured(t *testing.T) {
// TestWebSocket_RejectsConnectionWhenAtMaxClients verifies that when the hub
// is at capacity, new WebSocket upgrade requests are rejected with 503.
func TestWebSocket_RejectsConnectionWhenAtMaxClients(t *testing.T) {
- orig := maxWsClients
- maxWsClients = 0 // immediately at capacity
- t.Cleanup(func() { maxWsClients = orig })
-
srv, _ := testServer(t)
+ srv.hub.SetMaxClients(0) // immediately at capacity
srv.StartHub()
req := httptest.NewRequest("GET", "/api/ws", nil)