MCPcopy Index your code
hub / github.com/kopia/kopia / TestEnqueueBackAndProcess

Function TestEnqueueBackAndProcess

internal/parallelwork/parallel_work_queue_test.go:48–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestEnqueueBackAndProcess(t *testing.T) {
49 queue := parallelwork.NewQueue()
50
51 results := make(chan int, 3)
52
53 // Enqueue work items to the back of the queue
54 queue.EnqueueBack(context.Background(), func() error {
55 results <- 1
56 return nil
57 })
58 queue.EnqueueBack(context.Background(), func() error {
59 results <- 2
60 return nil
61 })
62 queue.EnqueueBack(context.Background(), func() error {
63 results <- 3
64 return nil
65 })
66
67 err := queue.Process(context.Background(), 2) // Use two workers
68 require.NoError(t, err)
69
70 close(results)
71
72 var sum int
73 for res := range results {
74 sum += res
75 }
76
77 require.Equal(t, 6, sum)
78}
79
80func TestProcessWithError(t *testing.T) {
81 queue := parallelwork.NewQueue()

Callers

nothing calls this directly

Calls 4

EnqueueBackMethod · 0.95
ProcessMethod · 0.95
NewQueueFunction · 0.92
EqualMethod · 0.80

Tested by

no test coverage detected