(_ *testing.T)
| 74 | } |
| 75 | |
| 76 | func TestDoneChanCloses(_ *testing.T) { |
| 77 | rb := &requestBatch{} |
| 78 | |
| 79 | const totalRequests = 3 |
| 80 | |
| 81 | ctx := context.Background() |
| 82 | cancelCtx, cancel := context.WithCancel(ctx) |
| 83 | |
| 84 | req := httptest.NewRequest("GET", "http://example.com", nil) |
| 85 | prequest := pipeline.NewHTTPRequest(req) |
| 86 | prequest.SetContext(cancelCtx) |
| 87 | |
| 88 | for i := 0; i < totalRequests-1; i++ { |
| 89 | _ = rb.add(&request{request: prequest}) |
| 90 | } |
| 91 | |
| 92 | wg := &sync.WaitGroup{} |
| 93 | wg.Add(1) |
| 94 | go func() { |
| 95 | done := rb.doneChan(make(<-chan struct{})) |
| 96 | <-done |
| 97 | wg.Done() |
| 98 | }() |
| 99 | |
| 100 | cancel() |
| 101 | wg.Wait() |
| 102 | // this test won't return unless doneChan closes |
| 103 | } |
| 104 | |
| 105 | func TestDoneChanClosesOnStop(_ *testing.T) { |
| 106 | rb := &requestBatch{} |
nothing calls this directly
no test coverage detected