-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconn_test.go
57 lines (41 loc) · 1003 Bytes
/
conn_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
55
56
57
package websocket
import (
"testing"
"github.com/fasthttp/websocket"
)
func Test_aquireConn(t *testing.T) {
if conn := acquireConn(); conn == nil {
t.Error("Conn is nil")
}
}
func Test_releaseConn(t *testing.T) {
wConn := new(websocket.Conn)
conn := acquireConn()
conn.Conn = wConn
conn.SetUserValue("key", "value")
releaseConn(conn)
if conn.Conn != nil {
t.Error("Conn is not nil")
}
if len(conn.values) > 0 {
t.Error("Conn.values has not been reset")
}
}
func Test_SetAndGetUserValue(t *testing.T) {
wConn := new(websocket.Conn)
conn := acquireConn()
conn.Conn = wConn
conn.SetUserValue("key", "value")
if val := conn.UserValue("key"); val == nil {
t.Error("UserValue is not saved")
}
}
func Test_SetAndGetUserValueBytes(t *testing.T) {
wConn := new(websocket.Conn)
conn := acquireConn()
conn.Conn = wConn
conn.SetUserValueBytes([]byte("key"), "value")
if val := conn.UserValueBytes([]byte("key")); val == nil {
t.Error("UserValue is not saved")
}
}