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

Function TestWebsocket_WriteBytesBinary

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

Source from the content-addressed store, hash-verified

648}
649
650func TestWebsocket_WriteBytesBinary(t *testing.T) {
651 type args struct {
652 wsConn WebsocketConn
653 wsPreSteps func(*Websocket)
654 content []byte
655 }
656 cases := []struct {
657 name string
658 args args
659 result chainResult
660 }{
661 {
662 name: "success",
663 args: args{
664 wsPreSteps: noWsPreSteps,
665 wsConn: &mockWebsocketConn{},
666 content: []byte("random message..."),
667 },
668 result: success,
669 },
670 {
671 name: "conn is nil",
672 args: args{
673 wsConn: nil,
674 wsPreSteps: noWsPreSteps,
675 content: []byte("random message..."),
676 },
677 result: failure,
678 },
679 {
680 name: "websocket unusable",
681 args: args{
682 wsConn: &mockWebsocketConn{},
683 wsPreSteps: func(ws *Websocket) {
684 ws.Disconnect()
685 },
686 content: []byte("random message..."),
687 },
688 result: failure,
689 },
690 }
691 for _, tc := range cases {
692 t.Run(tc.name, func(t *testing.T) {
693 reporter := newMockReporter(t)
694 chain := newChainWithDefaults("test", reporter)
695 config := newMockConfig(reporter)
696
697 ws := newWebsocket(chain, config, tc.args.wsConn)
698
699 tc.args.wsPreSteps(ws)
700
701 ws.WriteBytesBinary(tc.args.content)
702
703 ws.chain.assert(t, tc.result)
704 })
705 }
706}
707

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…