(f func(), concurrency int)
| 238 | } |
| 239 | |
| 240 | func testConcurrent(f func(), concurrency int) error { |
| 241 | ch := make(chan struct{}, concurrency) |
| 242 | for i := 0; i < concurrency; i++ { |
| 243 | go func() { |
| 244 | f() |
| 245 | ch <- struct{}{} |
| 246 | }() |
| 247 | } |
| 248 | for i := 0; i < concurrency; i++ { |
| 249 | select { |
| 250 | case <-ch: |
| 251 | case <-time.After(2 * time.Second): |
| 252 | return fmt.Errorf("timeout on %d iteration", i) |
| 253 | } |
| 254 | } |
| 255 | return nil |
| 256 | } |
| 257 | |
| 258 | func TestDecorateRequest(t *testing.T) { |
| 259 | testCases := []struct { |
no outgoing calls
no test coverage detected