[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
This commit is contained in:
Shulhan 2018-03-13 18:12:42 +07:00
parent a54dee31de
commit cbbf9f7e3b

View File

@ -30,10 +30,16 @@ func TestService(t *testing.T) {
// we can't test service.Init as it parses the command line // we can't test service.Init as it parses the command line
// service.Init() // service.Init()
// register handler t.Run("Run", func(t *testing.T) {
// do that later t.Parallel()
// run service
service.Run()
})
t.Run("Debug.Health", func(t *testing.T) {
t.Parallel()
go func() {
// wait for start // wait for start
wg.Wait() wg.Wait()
@ -57,8 +63,5 @@ func TestService(t *testing.T) {
// shutdown the service // shutdown the service
cancel() cancel()
}() })
// run service
service.Run()
} }