(t *testing.T)
| 275 | } |
| 276 | |
| 277 | func TestWebsocket_CloseWithBytes(t *testing.T) { |
| 278 | type args struct { |
| 279 | wsConn WebsocketConn |
| 280 | wsPreSteps func(*Websocket) |
| 281 | content []byte |
| 282 | closeCode []int |
| 283 | } |
| 284 | cases := []struct { |
| 285 | name string |
| 286 | args args |
| 287 | result chainResult |
| 288 | }{ |
| 289 | { |
| 290 | name: "success", |
| 291 | args: args{ |
| 292 | wsPreSteps: noWsPreSteps, |
| 293 | wsConn: &mockWebsocketConn{}, |
| 294 | content: []byte("connection closed..."), |
| 295 | closeCode: []int{websocket.CloseNormalClosure}, |
| 296 | }, |
| 297 | result: success, |
| 298 | }, |
| 299 | { |
| 300 | name: "conn is nil", |
| 301 | args: args{ |
| 302 | wsPreSteps: noWsPreSteps, |
| 303 | wsConn: nil, |
| 304 | content: []byte("connection closed..."), |
| 305 | closeCode: []int{websocket.CloseNormalClosure}, |
| 306 | }, |
| 307 | result: failure, |
| 308 | }, |
| 309 | { |
| 310 | name: "websocket unusable", |
| 311 | args: args{ |
| 312 | wsPreSteps: func(ws *Websocket) { |
| 313 | ws.Disconnect() |
| 314 | }, |
| 315 | wsConn: &mockWebsocketConn{}, |
| 316 | content: []byte("connection closed..."), |
| 317 | closeCode: []int{websocket.CloseNormalClosure}, |
| 318 | }, |
| 319 | result: failure, |
| 320 | }, |
| 321 | { |
| 322 | name: "too many close codes", |
| 323 | args: args{ |
| 324 | wsPreSteps: noWsPreSteps, |
| 325 | wsConn: &mockWebsocketConn{}, |
| 326 | content: []byte("connection closed..."), |
| 327 | closeCode: []int{websocket.CloseNormalClosure, websocket.CloseAbnormalClosure}, |
| 328 | }, |
| 329 | result: failure, |
| 330 | }, |
| 331 | } |
| 332 | for _, tc := range cases { |
| 333 | t.Run(tc.name, func(t *testing.T) { |
| 334 | reporter := newMockReporter(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…