From 1aea271363884f7d616d95971fd25b6c4d87de85 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 10 Mar 2026 23:58:00 +0000 Subject: test: sandbox coverage + fix WebSocket races MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- internal/api/websocket_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'internal/api/websocket_test.go') 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) -- cgit v1.2.3