Skip to content

Commit

Permalink
tests: extract drain-after-close in its own test
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Perrin <[email protected]>
  • Loading branch information
kaworu committed Feb 8, 2021
1 parent e8d3fbc commit 04b98b6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions workerpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,6 @@ func TestWorkerPool(t *testing.T) {
if err := wp.Close(); err != nil {
t.Errorf("close: got '%v', want no error", err)
}

results, err := wp.Drain()
if err != ErrClosed {
t.Errorf("drain: got '%v', want '%v'", err, ErrClosed)
}
if results != nil {
t.Errorf("drain: got '%v', want '%v'", results, nil)
}
}

func TestConcurrentDrain(t *testing.T) {
Expand Down Expand Up @@ -289,6 +281,18 @@ func TestConcurrentDrain(t *testing.T) {
}
}

func TestWorkerPoolDrainAfterClose(t *testing.T) {
wp := New(runtime.NumCPU())
wp.Close()
tasks, err := wp.Drain()
if err != ErrClosed {
t.Errorf("got %v; want %v", err, ErrClosed)
}
if tasks != nil {
t.Errorf("got %v as tasks; want %v", tasks, nil)
}
}

func TestWorkerPoolSubmitAfterClose(t *testing.T) {
wp := New(runtime.NumCPU())
wp.Close()
Expand Down

0 comments on commit 04b98b6

Please sign in to comment.