(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestRequestBatchBasics(t *testing.T) { |
| 19 | rb := &requestBatch{} |
| 20 | |
| 21 | const totalRequests = 3 |
| 22 | |
| 23 | for i := byte(0); i < totalRequests; i++ { |
| 24 | req := httptest.NewRequest("GET", "http://example.com", bytes.NewReader([]byte{i})) |
| 25 | _ = rb.add(&request{ |
| 26 | request: pipeline.NewHTTPRequest(req), |
| 27 | }) |
| 28 | } |
| 29 | |
| 30 | // confirm len |
| 31 | require.Equal(t, totalRequests, rb.len()) |
| 32 | |
| 33 | // confirm grpc requests are ordered |
| 34 | grpcRequests := rb.httpGrpcRequests() |
| 35 | require.Equal(t, totalRequests, len(grpcRequests)) |
| 36 | for i := byte(0); i < byte(len(grpcRequests)); i++ { |
| 37 | require.Equal(t, []byte{i}, grpcRequests[i].Body) |
| 38 | } |
| 39 | |
| 40 | // clear and confirm len |
| 41 | rb.clear() |
| 42 | require.Equal(t, 0, rb.len()) |
| 43 | |
| 44 | grpcRequests = rb.httpGrpcRequests() |
| 45 | require.Equal(t, 0, len(grpcRequests)) |
| 46 | } |
| 47 | |
| 48 | func TestRequestBatchContextError(t *testing.T) { |
| 49 | rb := &requestBatch{} |
nothing calls this directly
no test coverage detected