MCPcopy Create free account
hub / github.com/gavv/httpexpect / TestWebsocket_CloseWithBytes

Function TestWebsocket_CloseWithBytes

websocket_test.go:277–347  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

275}
276
277func TestWebsocket_CloseWithBytes(t *testing.T) {
278 type args struct {
279 wsConn WebsocketConn
280 wsPreSteps func(*Websocket)
281 content []byte
282 closeCode []int
283 }
284 cases := []struct {
285 name string
286 args args
287 result chainResult
288 }{
289 {
290 name: "success",
291 args: args{
292 wsPreSteps: noWsPreSteps,
293 wsConn: &mockWebsocketConn{},
294 content: []byte("connection closed..."),
295 closeCode: []int{websocket.CloseNormalClosure},
296 },
297 result: success,
298 },
299 {
300 name: "conn is nil",
301 args: args{
302 wsPreSteps: noWsPreSteps,
303 wsConn: nil,
304 content: []byte("connection closed..."),
305 closeCode: []int{websocket.CloseNormalClosure},
306 },
307 result: failure,
308 },
309 {
310 name: "websocket unusable",
311 args: args{
312 wsPreSteps: func(ws *Websocket) {
313 ws.Disconnect()
314 },
315 wsConn: &mockWebsocketConn{},
316 content: []byte("connection closed..."),
317 closeCode: []int{websocket.CloseNormalClosure},
318 },
319 result: failure,
320 },
321 {
322 name: "too many close codes",
323 args: args{
324 wsPreSteps: noWsPreSteps,
325 wsConn: &mockWebsocketConn{},
326 content: []byte("connection closed..."),
327 closeCode: []int{websocket.CloseNormalClosure, websocket.CloseAbnormalClosure},
328 },
329 result: failure,
330 },
331 }
332 for _, tc := range cases {
333 t.Run(tc.name, func(t *testing.T) {
334 reporter := newMockReporter(t)

Callers

nothing calls this directly

Calls 7

newMockReporterFunction · 0.85
newChainWithDefaultsFunction · 0.85
newMockConfigFunction · 0.85
newWebsocketFunction · 0.85
DisconnectMethod · 0.80
CloseWithBytesMethod · 0.80
assertMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…