(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func TestWebsocket_Expect(t *testing.T) { |
| 128 | type args struct { |
| 129 | chainFlags chainFlags |
| 130 | wsConn WebsocketConn |
| 131 | wsPreSteps func(*Websocket) |
| 132 | } |
| 133 | cases := []struct { |
| 134 | name string |
| 135 | args args |
| 136 | result chainResult |
| 137 | }{ |
| 138 | { |
| 139 | name: "success", |
| 140 | args: args{ |
| 141 | wsPreSteps: noWsPreSteps, |
| 142 | wsConn: &mockWebsocketConn{}, |
| 143 | }, |
| 144 | result: success, |
| 145 | }, |
| 146 | { |
| 147 | name: "fail to read message from conn", |
| 148 | args: args{ |
| 149 | wsPreSteps: noWsPreSteps, |
| 150 | wsConn: &mockWebsocketConn{ |
| 151 | readMsgErr: errors.New("failed to read message"), |
| 152 | }, |
| 153 | }, |
| 154 | result: failure, |
| 155 | }, |
| 156 | { |
| 157 | name: "chain already failed", |
| 158 | args: args{ |
| 159 | chainFlags: flagFailed, |
| 160 | wsPreSteps: noWsPreSteps, |
| 161 | wsConn: &mockWebsocketConn{}, |
| 162 | }, |
| 163 | result: failure, |
| 164 | }, |
| 165 | { |
| 166 | name: "conn is nil", |
| 167 | args: args{ |
| 168 | wsPreSteps: noWsPreSteps, |
| 169 | wsConn: nil, |
| 170 | }, |
| 171 | result: failure, |
| 172 | }, |
| 173 | { |
| 174 | name: "connection closed", |
| 175 | args: args{ |
| 176 | wsPreSteps: func(ws *Websocket) { |
| 177 | ws.Disconnect() |
| 178 | }, |
| 179 | wsConn: &mockWebsocketConn{}, |
| 180 | }, |
| 181 | result: failure, |
| 182 | }, |
| 183 | { |
| 184 | name: "failed to set read deadline", |
nothing calls this directly
no test coverage detected
searching dependent graphs…