(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestRequestBatchContextError(t *testing.T) { |
| 49 | rb := &requestBatch{} |
| 50 | ctx := context.Background() |
| 51 | const totalRequests = 3 |
| 52 | |
| 53 | req := httptest.NewRequest("GET", "http://example.com", nil) |
| 54 | prequest := pipeline.NewHTTPRequest(req) |
| 55 | prequest.SetContext(ctx) |
| 56 | |
| 57 | for i := 0; i < totalRequests-1; i++ { |
| 58 | _ = rb.add(&request{request: prequest}) |
| 59 | } |
| 60 | |
| 61 | // add a cancel context |
| 62 | cancelCtx, cancel := context.WithCancel(ctx) |
| 63 | prequest = pipeline.NewHTTPRequest(req) |
| 64 | prequest.SetContext(cancelCtx) |
| 65 | |
| 66 | _ = rb.add(&request{request: prequest}) |
| 67 | |
| 68 | // confirm ok |
| 69 | require.NoError(t, rb.contextError()) |
| 70 | |
| 71 | // cancel anc confirm error |
| 72 | cancel() |
| 73 | require.Error(t, rb.contextError()) |
| 74 | } |
| 75 | |
| 76 | func TestDoneChanCloses(_ *testing.T) { |
| 77 | rb := &requestBatch{} |
nothing calls this directly
no test coverage detected