(t *testing.T)
| 764 | } |
| 765 | |
| 766 | func TestWebsocket_WriteText(t *testing.T) { |
| 767 | type args struct { |
| 768 | wsConn WebsocketConn |
| 769 | wsPreSteps func(*Websocket) |
| 770 | content string |
| 771 | } |
| 772 | cases := []struct { |
| 773 | name string |
| 774 | args args |
| 775 | result chainResult |
| 776 | }{ |
| 777 | { |
| 778 | name: "success", |
| 779 | args: args{ |
| 780 | wsPreSteps: noWsPreSteps, |
| 781 | wsConn: &mockWebsocketConn{}, |
| 782 | content: "random message...", |
| 783 | }, |
| 784 | result: success, |
| 785 | }, |
| 786 | { |
| 787 | name: "conn is nil", |
| 788 | args: args{ |
| 789 | wsConn: nil, |
| 790 | wsPreSteps: noWsPreSteps, |
| 791 | content: "random message...", |
| 792 | }, |
| 793 | result: failure, |
| 794 | }, |
| 795 | { |
| 796 | name: "websocket unusable", |
| 797 | args: args{ |
| 798 | wsConn: &mockWebsocketConn{}, |
| 799 | wsPreSteps: func(ws *Websocket) { |
| 800 | ws.Disconnect() |
| 801 | }, |
| 802 | content: "random message...", |
| 803 | }, |
| 804 | result: failure, |
| 805 | }, |
| 806 | } |
| 807 | for _, tc := range cases { |
| 808 | t.Run(tc.name, func(t *testing.T) { |
| 809 | reporter := newMockReporter(t) |
| 810 | chain := newChainWithDefaults("test", reporter) |
| 811 | config := newMockConfig(reporter) |
| 812 | |
| 813 | ws := newWebsocket(chain, config, tc.args.wsConn) |
| 814 | |
| 815 | tc.args.wsPreSteps(ws) |
| 816 | |
| 817 | ws.WriteText(tc.args.content) |
| 818 | |
| 819 | ws.chain.assert(t, tc.result) |
| 820 | }) |
| 821 | } |
| 822 | } |
| 823 |
nothing calls this directly
no test coverage detected
searching dependent graphs…