(t *testing.T)
| 706 | } |
| 707 | |
| 708 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…