| 103 | } |
| 104 | |
| 105 | func TestDoneChanClosesOnStop(_ *testing.T) { |
| 106 | rb := &requestBatch{} |
| 107 | |
| 108 | const totalRequests = 3 |
| 109 | req := httptest.NewRequest("GET", "http://example.com", nil) |
| 110 | |
| 111 | for i := 0; i < totalRequests-1; i++ { |
| 112 | _ = rb.add(&request{ |
| 113 | request: pipeline.NewHTTPRequest(req), |
| 114 | }) |
| 115 | } |
| 116 | |
| 117 | stop := make(chan struct{}) |
| 118 | wg := &sync.WaitGroup{} |
| 119 | wg.Add(1) |
| 120 | go func() { |
| 121 | done := rb.doneChan(stop) |
| 122 | <-done |
| 123 | wg.Done() |
| 124 | }() |
| 125 | |
| 126 | close(stop) |
| 127 | wg.Wait() |
| 128 | // this test won't return unless doneChan closes on stop |
| 129 | } |
| 130 | |
| 131 | func TestErrorsPropagateUpstream(t *testing.T) { |
| 132 | rb := &requestBatch{} |