MCPcopy
hub / github.com/coder/websocket / setupTest

Function setupTest

internal/examples/chat/chat_test.go:123–135  ·  view source on GitHub ↗

setupTest sets up chatServer that can be used via the returned url. Defer closeFn to ensure everything is cleaned up at the end of the test. chatServer logs will be logged via t.Logf.

(t *testing.T)

Source from the content-addressed store, hash-verified

121//
122// chatServer logs will be logged via t.Logf.
123func setupTest(t *testing.T) (url string, closeFn func()) {
124 cs := newChatServer()
125 cs.logf = t.Logf
126
127 // To ensure tests run quickly under even -race.
128 cs.subscriberMessageBuffer = 4096
129 cs.publishLimiter.SetLimit(rate.Inf)
130
131 s := httptest.NewServer(cs)
132 return s.URL, func() {
133 s.Close()
134 }
135}
136
137// testAllMessagesReceived ensures that after n reads, all msgs in msgs
138// have been read.

Callers 1

Test_chatServerFunction · 0.85

Calls 2

newChatServerFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…