TestDebounceFirstDataRace tests for data races.
(t *testing.T)
| 25 | |
| 26 | // TestDebounceFirstDataRace tests for data races. |
| 27 | func TestDebounceFirstDataRace(t *testing.T) { |
| 28 | ctx := context.Background() |
| 29 | |
| 30 | circuit := failAfter(1) |
| 31 | debounce := DebounceFirst(circuit, time.Second) |
| 32 | |
| 33 | wg := sync.WaitGroup{} |
| 34 | |
| 35 | for count := 1; count <= 10; count++ { |
| 36 | wg.Add(1) |
| 37 | |
| 38 | go func(count int) { |
| 39 | defer wg.Done() |
| 40 | |
| 41 | time.Sleep(50 * time.Millisecond) |
| 42 | |
| 43 | _, err := debounce(ctx) |
| 44 | |
| 45 | t.Logf("attempt %d: err=%v", count, err) |
| 46 | }(count) |
| 47 | } |
| 48 | |
| 49 | time.Sleep(time.Second * 2) |
| 50 | |
| 51 | for count := 1; count <= 10; count++ { |
| 52 | wg.Add(1) |
| 53 | |
| 54 | go func(count int) { |
| 55 | defer wg.Done() |
| 56 | |
| 57 | time.Sleep(50 * time.Millisecond) |
| 58 | |
| 59 | _, err := debounce(ctx) |
| 60 | |
| 61 | t.Logf("attempt %d: err=%v", count, err) |
| 62 | }(count) |
| 63 | } |
| 64 | |
| 65 | wg.Wait() |
| 66 | } |
nothing calls this directly
no test coverage detected