MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestForEachUser

Function TestForEachUser

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

Source from the content-addressed store, hash-verified

13)
14
15func 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
37func TestForEachUser_ShouldContinueOnErrorButReturnIt(t *testing.T) {
38 var (

Callers

nothing calls this directly

Calls 1

ForEachUserFunction · 0.85

Tested by

no test coverage detected