MCPcopy
hub / github.com/olahol/melody / TestClose

Function TestClose

melody_test.go:285–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

283}
284
285func TestClose(t *testing.T) {
286 ws := NewTestServer()
287
288 server := httptest.NewServer(ws)
289 defer server.Close()
290
291 n := 10
292
293 conns := make([]*websocket.Conn, n)
294 for i := range conns {
295 conn := MustNewDialer(server.URL)
296 conns[i] = conn
297 defer conns[i].Close()
298 }
299
300 q := make(chan bool)
301 ws.m.HandleDisconnect(func(s *Session) {
302 q <- true
303 })
304
305 ws.m.Close()
306
307 for _, conn := range conns {
308 conn.ReadMessage()
309 }
310
311 assert.Zero(t, ws.m.Len())
312
313 m := 0
314 for range q {
315 m += 1
316 if m == n {
317 break
318 }
319 }
320}
321
322func TestLen(t *testing.T) {
323 rand.Seed(time.Now().UnixNano())

Callers

nothing calls this directly

Calls 5

NewTestServerFunction · 0.85
MustNewDialerFunction · 0.85
HandleDisconnectMethod · 0.80
LenMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…