MCPcopy Index your code
hub / github.com/gobwas/ws / TestControlHandler

Function TestControlHandler

wsutil/handler_test.go:11–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestControlHandler(t *testing.T) {
12 for _, test := range []struct {
13 name string
14 state ws.State
15 in ws.Frame
16 out ws.Frame
17 noOut bool
18 err error
19 }{
20 {
21 name: "ping",
22 in: ws.NewPingFrame(nil),
23 out: ws.NewPongFrame(nil),
24 },
25 {
26 name: "ping",
27 in: ws.NewPingFrame([]byte("catch the ball")),
28 out: ws.NewPongFrame([]byte("catch the ball")),
29 },
30 {
31 name: "ping",
32 state: ws.StateServerSide,
33 in: ws.MaskFrame(ws.NewPingFrame([]byte("catch the ball"))),
34 out: ws.NewPongFrame([]byte("catch the ball")),
35 },
36 {
37 name: "ping",
38 in: ws.NewPingFrame(bytes.Repeat([]byte{0xfe}, 125)),
39 out: ws.NewPongFrame(bytes.Repeat([]byte{0xfe}, 125)),
40 },
41 {
42 name: "pong",
43 in: ws.NewPongFrame(nil),
44 noOut: true,
45 },
46 {
47 name: "pong",
48 in: ws.NewPongFrame([]byte("caught")),
49 noOut: true,
50 },
51 {
52 name: "close",
53 in: ws.NewCloseFrame(nil),
54 out: ws.NewCloseFrame(nil),
55 err: ClosedError{
56 Code: ws.StatusNoStatusRcvd,
57 },
58 },
59 {
60 name: "close",
61 in: ws.NewCloseFrame(ws.NewCloseFrameBody(
62 ws.StatusGoingAway, "goodbye!",
63 )),
64 out: ws.NewCloseFrame(ws.NewCloseFrameBody(
65 ws.StatusGoingAway, "",
66 )),
67 err: ClosedError{
68 Code: ws.StatusGoingAway,

Callers

nothing calls this directly

Calls 11

HandleMethod · 0.95
NewPingFrameFunction · 0.92
NewPongFrameFunction · 0.92
MaskFrameFunction · 0.92
NewCloseFrameFunction · 0.92
NewCloseFrameBodyFunction · 0.92
MustCompileFrameFunction · 0.92
MustReadFrameFunction · 0.92
BytesMethod · 0.65
ErrorMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…