From b7a377fd6eda98e77f13875a28aa533eefd19737 Mon Sep 17 00:00:00 2001 From: Alexandre Perrin Date: Fri, 5 Feb 2021 11:15:53 +0100 Subject: [PATCH] tests: extract drain-after-close in its own test Signed-off-by: Alexandre Perrin --- workerpool_test.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/workerpool_test.go b/workerpool_test.go index 779b8e7..6aff475 100644 --- a/workerpool_test.go +++ b/workerpool_test.go @@ -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) { @@ -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()