From b8e2cd0c9481abd59700565678948b466ed1e505 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Tue, 24 Dec 2019 16:47:08 +0400 Subject: [PATCH] Add "already restarting" test case --- pkg/restart/restart_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/restart/restart_test.go b/pkg/restart/restart_test.go index 80e291c92..e0c118add 100644 --- a/pkg/restart/restart_test.go +++ b/pkg/restart/restart_test.go @@ -66,6 +66,25 @@ func TestContext_Restart(t *testing.T) { assert.Equal(t, ErrMalformedArgs, cc.Restart()) }) + + t.Run("already restarting", func(t *testing.T) { + cc.args = nil + + cmd := "touch" + path := "/tmp/test_restart" + args := []string{cmd, path} + cc.args = args + + ch := make(chan error, 1) + go func() { + ch <- cc.Restart() + }() + + assert.NoError(t, cc.Restart()) + assert.NoError(t, os.Remove(path)) + + assert.Equal(t, ErrAlreadyRestarting, <-ch) + }) } func TestContext_SetCheckDelay(t *testing.T) {