(t *testing.T)
| 163 | } |
| 164 | |
| 165 | func TestGenericCombinerDoesntRace(t *testing.T) { |
| 166 | combiner := newTestCombiner() |
| 167 | end := make(chan struct{}) |
| 168 | wg := sync.WaitGroup{} |
| 169 | |
| 170 | concurrent := func(f func()) { |
| 171 | wg.Add(1) |
| 172 | go func() { |
| 173 | defer wg.Done() |
| 174 | for { |
| 175 | select { |
| 176 | case <-end: |
| 177 | return |
| 178 | default: |
| 179 | f() |
| 180 | } |
| 181 | } |
| 182 | }() |
| 183 | } |
| 184 | concurrent(func() { |
| 185 | _ = combiner.AddResponse(newTestResponse(t)) |
| 186 | }) |
| 187 | |
| 188 | concurrent(func() { |
| 189 | // this test is going to add a failed response which cuts off certain code paths. just wait a bit to test the other paths |
| 190 | time.Sleep(10 * time.Millisecond) |
| 191 | _ = combiner.AddResponse(newFailedTestResponse()) |
| 192 | }) |
| 193 | |
| 194 | concurrent(func() { |
| 195 | combiner.ShouldQuit() |
| 196 | }) |
| 197 | |
| 198 | concurrent(func() { |
| 199 | combiner.StatusCode() |
| 200 | }) |
| 201 | |
| 202 | concurrent(func() { |
| 203 | _, _ = combiner.HTTPFinal() |
| 204 | }) |
| 205 | |
| 206 | concurrent(func() { |
| 207 | _, _ = combiner.GRPCFinal() |
| 208 | }) |
| 209 | |
| 210 | concurrent(func() { |
| 211 | _, _ = combiner.GRPCDiff() |
| 212 | }) |
| 213 | |
| 214 | close(end) |
| 215 | wg.Wait() |
| 216 | } |
| 217 | |
| 218 | type testPipelineResponse struct { |
| 219 | r *http.Response |
nothing calls this directly
no test coverage detected