From 8ae03c32faec70ffa0197780df7c779675cd55b5 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Tue, 28 Jan 2020 09:53:48 -0500 Subject: [PATCH] tests: defer closing shutdownCh --- nomad/util_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nomad/util_test.go b/nomad/util_test.go index 67bd5cab9..bb6f68620 100644 --- a/nomad/util_test.go +++ b/nomad/util_test.go @@ -263,6 +263,7 @@ func TestMaxUint64(t *testing.T) { func TestDropButLastChannelDropsValues(t *testing.T) { sourceCh := make(chan bool) shutdownCh := make(chan struct{}) + defer close(shutdownCh) dstCh := dropButLastChannel(sourceCh, shutdownCh) @@ -327,8 +328,6 @@ func TestDropButLastChannelDropsValues(t *testing.T) { case <-time.After(timeoutDuration): require.Fail(t, "timed out waiting for source->dstCh propagation") } - - close(shutdownCh) } // TestDropButLastChannel_DeliversMessages asserts that last @@ -338,6 +337,7 @@ func TestDropButLastChannelDropsValues(t *testing.T) { func TestDropButLastChannel_DeliversMessages(t *testing.T) { sourceCh := make(chan bool) shutdownCh := make(chan struct{}) + defer close(shutdownCh) dstCh := dropButLastChannel(sourceCh, shutdownCh) @@ -386,6 +386,7 @@ RECEIVE_LOOP: func TestDropButLastChannel_DeliversMessages_Close(t *testing.T) { sourceCh := make(chan bool) shutdownCh := make(chan struct{}) + defer close(shutdownCh) dstCh := dropButLastChannel(sourceCh, shutdownCh)