Skip to content

24 server tests passing, race-free - #7

Open
opencode-agent[bot] wants to merge 1 commit into
mainfrom
opencode/issue2-20260729032834
Open

24 server tests passing, race-free#7
opencode-agent[bot] wants to merge 1 commit into
mainfrom
opencode/issue2-20260729032834

Conversation

@opencode-agent

Copy link
Copy Markdown

All 24 tests pass clean (including -race). Created server/websocket_test.go with:

  • sanitizeInput (8 tests): normal text, ANSI stripping, control char removal, newline/tab preservation, whitespace trimming, empty/whitespace-only input, unicode
  • defaultColorForNick (3 tests): determinism, valid palette colors for various nicks including empty string
  • broadcastToRoom (6 tests): message delivery to all clients, history accumulation, history cap at 30, slow client drop, non-existent room no-op, non-message types not recorded in history
  • cleanupClient (7 tests): client removal, host transfer to oldest remaining client, empty room deletion, leave message broadcast, host transfer message broadcast, no host transfer on empty room, host unchanged when non-host leaves

Uses standard testing package with channel-based fake clients for broadcastToRoom and httptest-backed real websocket connections for cleanupClient. Follows existing project conventions (t.Fatal/t.Fatalf assertions, no external libraries).

Closes #2

New%20session%20-%202026-07-29T03%3A28%3A33.850Z
opencode session  |  github run

Co-authored-by: ishaan-jindal <ishaan-jindal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for the server package

0 participants