eleven / messenger Public

Clone
git clone https://amadan.net/eleven/messenger

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3import "testing"
4
5// TestHubShutdown checks that shutdown() closes every connected client's send
6// channel (which ends its writer and closes the socket, so browsers reconnect).
7func TestHubShutdown(t *testing.T) {
8 h := newHub()
9 go h.run()
10 c := &client{send: make(chan []byte, 1)}
11 h.register <- c
12 h.shutdown()
13 select {
14 case _, ok := <-c.send:
15 if ok {
16 t.Fatal("send channel should be closed after shutdown")
17 }
18 default:
19 t.Fatal("send channel not closed after shutdown")
20 }
21}
22