(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestForEachUser(t *testing.T) { |
| 16 | var ( |
| 17 | ctx = context.Background() |
| 18 | |
| 19 | // Keep track of processed users. |
| 20 | processedMx sync.Mutex |
| 21 | processed []string |
| 22 | ) |
| 23 | |
| 24 | input := []string{"a", "b", "c"} |
| 25 | |
| 26 | err := ForEachUser(ctx, input, 2, func(ctx context.Context, user string) error { |
| 27 | processedMx.Lock() |
| 28 | defer processedMx.Unlock() |
| 29 | processed = append(processed, user) |
| 30 | return nil |
| 31 | }) |
| 32 | |
| 33 | require.NoError(t, err) |
| 34 | assert.ElementsMatch(t, input, processed) |
| 35 | } |
| 36 | |
| 37 | func TestForEachUser_ShouldContinueOnErrorButReturnIt(t *testing.T) { |
| 38 | var ( |
nothing calls this directly
no test coverage detected