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

Function TestWebsocket_WriteBytesText

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

Source from the content-addressed store, hash-verified

706}
707
708func TestWebsocket_WriteBytesText(t *testing.T) {
709 type args struct {
710 wsConn WebsocketConn
711 wsPreSteps func(*Websocket)
712 content []byte
713 }
714 cases := []struct {
715 name string
716 args args
717 result chainResult
718 }{
719 {
720 name: "success",
721 args: args{
722 wsPreSteps: noWsPreSteps,
723 wsConn: &mockWebsocketConn{},
724 content: []byte("random message..."),
725 },
726 result: success,
727 },
728 {
729 name: "conn is nil",
730 args: args{
731 wsConn: nil,
732 wsPreSteps: noWsPreSteps,
733 content: []byte("random message..."),
734 },
735 result: failure,
736 },
737 {
738 name: "websocket unusable",
739 args: args{
740 wsConn: &mockWebsocketConn{},
741 wsPreSteps: func(ws *Websocket) {
742 ws.Disconnect()
743 },
744 content: []byte("random message..."),
745 },
746 result: failure,
747 },
748 }
749 for _, tc := range cases {
750 t.Run(tc.name, func(t *testing.T) {
751 reporter := newMockReporter(t)
752 chain := newChainWithDefaults("test", reporter)
753 config := newMockConfig(reporter)
754
755 ws := newWebsocket(chain, config, tc.args.wsConn)
756
757 tc.args.wsPreSteps(ws)
758
759 ws.WriteBytesText(tc.args.content)
760
761 ws.chain.assert(t, tc.result)
762 })
763 }
764}
765

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…