forked from gavv/httpexpect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
websocket_test.go
54 lines (39 loc) · 950 Bytes
/
websocket_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package httpexpect
import (
"testing"
"github.com/gorilla/websocket"
)
func TestWebsocketFailed(t *testing.T) {
chain := makeChain(newMockReporter(t))
chain.fail("fail")
ws := &Websocket{
chain: chain,
}
ws.chain.assertFailed(t)
ws.Raw()
ws.WithReadTimeout(0)
ws.WithoutReadTimeout()
ws.WithWriteTimeout(0)
ws.WithoutWriteTimeout()
ws.Subprotocol().chain.assertFailed(t)
ws.Expect().chain.assertFailed(t)
ws.WriteMessage(websocket.TextMessage, []byte("a"))
ws.WriteBytesBinary([]byte("a"))
ws.WriteBytesText([]byte("a"))
ws.WriteText("a")
ws.WriteJSON(map[string]string{"a": "b"})
ws.Close()
ws.CloseWithBytes([]byte("a"))
ws.CloseWithJSON(map[string]string{"a": "b"})
ws.CloseWithText("a")
ws.Disconnect()
}
func TestWebsocketNil(t *testing.T) {
config := Config{
Reporter: newMockReporter(t),
}
ws := NewWebsocket(config, nil)
msg := ws.Expect()
msg.chain.assertFailed(t)
ws.chain.assertFailed(t)
}