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 <alex@kaworu.ch>
  • Loading branch information
kaworu committed Feb 5, 2021
1 parent a5d4282 commit b7a377f
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 @@ -198,14 +198,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 @@ -287,6 +279,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 b7a377f

Please sign in to comment.