(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestConn(t *testing.T) { |
| 30 | t.Parallel() |
| 31 | |
| 32 | t.Run("fuzzData", func(t *testing.T) { |
| 33 | t.Parallel() |
| 34 | |
| 35 | compressionMode := func() websocket.CompressionMode { |
| 36 | return websocket.CompressionMode(xrand.Int(int(websocket.CompressionContextTakeover) + 1)) |
| 37 | } |
| 38 | |
| 39 | for range 5 { |
| 40 | t.Run("", func(t *testing.T) { |
| 41 | tt, c1, c2 := newConnTest(t, &websocket.DialOptions{ |
| 42 | CompressionMode: compressionMode(), |
| 43 | CompressionThreshold: xrand.Int(9999), |
| 44 | }, &websocket.AcceptOptions{ |
| 45 | CompressionMode: compressionMode(), |
| 46 | CompressionThreshold: xrand.Int(9999), |
| 47 | }) |
| 48 | |
| 49 | tt.goEchoLoop(c2) |
| 50 | |
| 51 | c1.SetReadLimit(131072) |
| 52 | |
| 53 | for range 5 { |
| 54 | err := wstest.Echo(tt.ctx, c1, 131072) |
| 55 | assert.Success(t, err) |
| 56 | } |
| 57 | |
| 58 | err := c1.Close(websocket.StatusNormalClosure, "") |
| 59 | assert.Success(t, err) |
| 60 | }) |
| 61 | } |
| 62 | }) |
| 63 | |
| 64 | t.Run("badClose", func(t *testing.T) { |
| 65 | tt, c1, c2 := newConnTest(t, nil, nil) |
| 66 | |
| 67 | c2.CloseRead(tt.ctx) |
| 68 | |
| 69 | err := c1.Close(-1, "") |
| 70 | assert.Contains(t, err, "failed to marshal close frame: status code StatusCode(-1) cannot be set") |
| 71 | }) |
| 72 | |
| 73 | t.Run("ping", func(t *testing.T) { |
| 74 | tt, c1, c2 := newConnTest(t, nil, nil) |
| 75 | |
| 76 | c1.CloseRead(tt.ctx) |
| 77 | c2.CloseRead(tt.ctx) |
| 78 | |
| 79 | for range 10 { |
| 80 | err := c1.Ping(tt.ctx) |
| 81 | assert.Success(t, err) |
| 82 | } |
| 83 | |
| 84 | err := c1.Close(websocket.StatusNormalClosure, "") |
| 85 | assert.Success(t, err) |
| 86 | }) |
nothing calls this directly
no test coverage detected
searching dependent graphs…