MCPcopy
hub / github.com/kopia/kopia / TestProcessWithError

Function TestProcessWithError

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

Source from the content-addressed store, hash-verified

78}
79
80func TestProcessWithError(t *testing.T) {
81 queue := parallelwork.NewQueue()
82
83 testError := errors.New("test error") //nolint:err113
84
85 // Enqueue work items, one of them returns an error
86 queue.EnqueueBack(context.Background(), func() error {
87 time.Sleep(100 * time.Millisecond)
88 return nil
89 })
90 queue.EnqueueBack(context.Background(), func() error {
91 return testError
92 })
93 queue.EnqueueBack(context.Background(), func() error {
94 time.Sleep(100 * time.Millisecond)
95 return nil
96 })
97
98 err := queue.Process(context.Background(), 2) // Use two workers
99 require.Equal(t, testError, err)
100}
101
102func TestWaitForActiveWorkers(t *testing.T) {
103 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