(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestEnqueueFrontAndProcess(t *testing.T) { |
| 17 | queue := parallelwork.NewQueue() |
| 18 | |
| 19 | results := make(chan int, 3) |
| 20 | |
| 21 | // Enqueue work items to the front of the queue |
| 22 | queue.EnqueueFront(context.Background(), func() error { |
| 23 | results <- 3 |
| 24 | return nil |
| 25 | }) |
| 26 | queue.EnqueueFront(context.Background(), func() error { |
| 27 | results <- 2 |
| 28 | return nil |
| 29 | }) |
| 30 | queue.EnqueueFront(context.Background(), func() error { |
| 31 | results <- 1 |
| 32 | return nil |
| 33 | }) |
| 34 | |
| 35 | err := queue.Process(context.Background(), 2) // Use two workers |
| 36 | require.NoError(t, err) |
| 37 | |
| 38 | close(results) |
| 39 | |
| 40 | var sum int |
| 41 | for res := range results { |
| 42 | sum += res |
| 43 | } |
| 44 | |
| 45 | require.Equal(t, 6, sum) |
| 46 | } |
| 47 | |
| 48 | func TestEnqueueBackAndProcess(t *testing.T) { |
| 49 | queue := parallelwork.NewQueue() |
nothing calls this directly
no test coverage detected