(t *testing.T)
| 60 | } |
| 61 | |
| 62 | func TestCloseBehavior(t *testing.T) { |
| 63 | q := queue.NewTaskQueue[int]() |
| 64 | done := make(chan struct{}) |
| 65 | // consumer |
| 66 | go func() { |
| 67 | _, err := q.Get() |
| 68 | if err == nil { |
| 69 | t.Errorf("expected error when getting from closed empty queue, got nil") |
| 70 | } |
| 71 | close(done) |
| 72 | }() |
| 73 | // allow goroutine to block |
| 74 | |
| 75 | // close queue |
| 76 | q.Close() |
| 77 | <-done |
| 78 | } |
| 79 | |
| 80 | func TestConcurrencySafety(t *testing.T) { |
| 81 | q := queue.NewTaskQueue[int]() |