From cbbf9f7e3b6f070ca14e27612c99c9230bdf8626 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Tue, 13 Mar 2018 18:12:42 +0700 Subject: [PATCH] [test] service.TestService: run subtest in parallel Reason: the t.Fatalf and t.Fatal must be invoked by test routine, not by other routine, or the the test will not stopped [1]. [1] megacheck SA2002 --- service_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/service_test.go b/service_test.go index 6dcc19cc..29e979f8 100644 --- a/service_test.go +++ b/service_test.go @@ -30,10 +30,16 @@ func TestService(t *testing.T) { // we can't test service.Init as it parses the command line // service.Init() - // register handler - // do that later + t.Run("Run", func(t *testing.T) { + t.Parallel() + + // run service + service.Run() + }) + + t.Run("Debug.Health", func(t *testing.T) { + t.Parallel() - go func() { // wait for start wg.Wait() @@ -57,8 +63,5 @@ func TestService(t *testing.T) { // shutdown the service cancel() - }() - - // run service - service.Run() + }) }