From 5edc17cb9e3b1d46f5cf427b72165aac0a6ad95c Mon Sep 17 00:00:00 2001 From: Ivan Stankov Date: Thu, 2 Feb 2023 18:01:24 +0200 Subject: [PATCH] TestShutdownEmpty --- batcher/batcher.go | 6 ++++-- batcher/batcher_test.go | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/batcher/batcher.go b/batcher/batcher.go index 6aed64a..544e48f 100644 --- a/batcher/batcher.go +++ b/batcher/batcher.go @@ -111,8 +111,10 @@ func (b *Batcher) Shutdown(wait bool) { b.flush() if wait { - // wait done channel - <-b.done + if b.done != nil { + // wait done channel + <-b.done + } } } diff --git a/batcher/batcher_test.go b/batcher/batcher_test.go index bff13a7..9115b20 100644 --- a/batcher/batcher_test.go +++ b/batcher/batcher_test.go @@ -88,6 +88,11 @@ func TestShutdownSuccess(t *testing.T) { } } +func TestShutdownEmpty(t *testing.T) { + b := New(10*time.Millisecond, returnsSuccess) + b.Shutdown(true) +} + func TestBatcherError(t *testing.T) { b := New(10*time.Millisecond, returnsError)