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

Function TestWebsocket_CloseWithText

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

Source from the content-addressed store, hash-verified

347}
348
349func TestWebsocket_CloseWithText(t *testing.T) {
350 type args struct {
351 wsConn WebsocketConn
352 wsPreSteps func(*Websocket)
353 content string
354 closeCode []int
355 }
356 cases := []struct {
357 name string
358 args args
359 result chainResult
360 }{
361 {
362 name: "success",
363 args: args{
364 wsPreSteps: noWsPreSteps,
365 wsConn: &mockWebsocketConn{},
366 content: "connection closed...",
367 closeCode: []int{websocket.CloseNormalClosure},
368 },
369 result: success,
370 },
371 {
372 name: "conn is nil",
373 args: args{
374 wsPreSteps: noWsPreSteps,
375 wsConn: nil,
376 content: "connection closed...",
377 closeCode: []int{websocket.CloseNormalClosure},
378 },
379 result: failure,
380 },
381 {
382 name: "websocket unusable",
383 args: args{
384 wsPreSteps: func(ws *Websocket) {
385 ws.Disconnect()
386 },
387 wsConn: &mockWebsocketConn{},
388 content: "connection closed...",
389 closeCode: []int{websocket.CloseNormalClosure},
390 },
391 result: failure,
392 },
393 {
394 name: "too many close codes",
395 args: args{
396 wsPreSteps: noWsPreSteps,
397 wsConn: &mockWebsocketConn{},
398 content: "connection closed...",
399 closeCode: []int{websocket.CloseNormalClosure, websocket.CloseAbnormalClosure},
400 },
401 result: failure,
402 },
403 }
404 for _, tc := range cases {
405 t.Run(tc.name, func(t *testing.T) {
406 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
CloseWithTextMethod · 0.80
assertMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…