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