MCPcopy
hub / github.com/grafana/dskit / TestForEachUser

Function TestForEachUser

concurrency/runner_test.go:17–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func 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
37func TestForEachUser_ShouldContinueOnErrorButReturnIt(t *testing.T) {
38 // Keep the processed users count.

Callers

nothing calls this directly

Calls 1

ForEachUserFunction · 0.85

Tested by

no test coverage detected