nolint:paralleltest // this tests uses timings to determine if it's working
(t *testing.T)
| 18 | |
| 19 | //nolint:paralleltest // this tests uses timings to determine if it's working |
| 20 | func Test_LinearExecutionStrategy(t *testing.T) { |
| 21 | var ( |
| 22 | lastSeenI atomic.Int64 |
| 23 | count atomic.Int64 |
| 24 | ) |
| 25 | lastSeenI.Store(-1) |
| 26 | runs, fns := strategyTestData(100, func(_ context.Context, i int, _ io.Writer) error { |
| 27 | count.Add(1) |
| 28 | swapped := lastSeenI.CompareAndSwap(int64(i-1), int64(i)) |
| 29 | assert.True(t, swapped) |
| 30 | time.Sleep(2 * time.Millisecond) |
| 31 | |
| 32 | if i%2 == 0 { |
| 33 | return xerrors.New("error") |
| 34 | } |
| 35 | return nil |
| 36 | }) |
| 37 | |
| 38 | strategy := harness.LinearExecutionStrategy{} |
| 39 | runErrs, err := strategy.Run(context.Background(), fns) |
| 40 | require.NoError(t, err) |
| 41 | require.Len(t, runErrs, 50) |
| 42 | require.EqualValues(t, 100, count.Load()) |
| 43 | |
| 44 | lastStartTime := time.Time{} |
| 45 | for _, run := range runs { |
| 46 | startTime := run.Result().StartedAt |
| 47 | require.True(t, startTime.After(lastStartTime)) |
| 48 | lastStartTime = startTime |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | //nolint:paralleltest // this tests uses timings to determine if it's working |
| 53 | func Test_ConcurrentExecutionStrategy(t *testing.T) { |
nothing calls this directly
no test coverage detected