(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func 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 | |
| 80 | func TestProcessWithError(t *testing.T) { |
| 81 | queue := parallelwork.NewQueue() |
nothing calls this directly
no test coverage detected