mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 00:17:07 +08:00
Fix test
This commit is contained in:
@@ -42,14 +42,20 @@ func TestProcess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestReconnectProcess(t *testing.T) {
|
func TestReconnectProcess(t *testing.T) {
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(1)
|
||||||
|
|
||||||
p, _ := New(Config{
|
p, _ := New(Config{
|
||||||
Binary: "sleep",
|
Binary: "sleep",
|
||||||
Args: []string{
|
Args: []string{
|
||||||
"2",
|
"2",
|
||||||
},
|
},
|
||||||
Reconnect: true,
|
Reconnect: true,
|
||||||
ReconnectDelay: 2 * time.Second,
|
ReconnectDelay: 10 * time.Second,
|
||||||
StaleTimeout: 0,
|
StaleTimeout: 0,
|
||||||
|
OnExit: func(string) {
|
||||||
|
wg.Done()
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
p.Start()
|
p.Start()
|
||||||
@@ -62,6 +68,8 @@ func TestReconnectProcess(t *testing.T) {
|
|||||||
return p.Status().State == "finished"
|
return p.Status().State == "finished"
|
||||||
}, 10*time.Second, 500*time.Millisecond)
|
}, 10*time.Second, 500*time.Millisecond)
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
require.Greater(t, p.Status().Reconnect, time.Duration(0))
|
require.Greater(t, p.Status().Reconnect, time.Duration(0))
|
||||||
|
|
||||||
p.Stop(false)
|
p.Stop(false)
|
||||||
|
Reference in New Issue
Block a user