From b7e0afc7a7f39aab185dd5c1994e6511a788b4a7 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Sat, 29 Apr 2023 08:26:22 +0200 Subject: [PATCH] Fix tests --- process/process_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/process/process_test.go b/process/process_test.go index a6593555..722324a3 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -54,6 +54,10 @@ func TestReconnectProcess(t *testing.T) { p.Start() + require.Eventually(t, func() bool { + return p.Status().State == "running" + }, 10*time.Second, 500*time.Millisecond) + require.Eventually(t, func() bool { return p.Status().State == "finished" }, 10*time.Second, 500*time.Millisecond) @@ -565,6 +569,9 @@ func TestProcessCallbacks(t *testing.T) { onState := []string{} lock := sync.Mutex{} + wg := sync.WaitGroup{} + + wg.Add(1) p, err := New(Config{ Binary: "sleep", @@ -599,6 +606,8 @@ func TestProcessCallbacks(t *testing.T) { defer lock.Unlock() onExit = state + + wg.Done() }, OnStateChange: func(from, to string) { lock.Lock() @@ -620,6 +629,8 @@ func TestProcessCallbacks(t *testing.T) { return p.Status().State == "finished" }, 10*time.Second, 500*time.Millisecond) + wg.Wait() + lock.Lock() require.ElementsMatch(t, []string{"2"}, args) require.True(t, onBeforeStart)