Fix tests

This commit is contained in:
Ingo Oppermann 2023-04-29 08:26:22 +02:00
parent f0a7564c55
commit b7e0afc7a7
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -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)