(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestForEachUser(t *testing.T) { |
| 18 | var ( |
| 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(context.Background(), input, 2, func(_ 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 | // Keep the processed users count. |
nothing calls this directly
no test coverage detected