|
|
@ -35,9 +35,15 @@ func Test_start_shouldFatalAfterTimeout_ifNotInitialized(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
datastore := i.NewDatastore(i.WithUsers([]portainer.User{}))
|
|
|
|
datastore := i.NewDatastore(i.WithUsers([]portainer.User{}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ch := make(chan struct{})
|
|
|
|
var fataled bool
|
|
|
|
var fataled bool
|
|
|
|
origLogFatalf := logFatalf
|
|
|
|
origLogFatalf := logFatalf
|
|
|
|
logFatalf = func(s string, v ...interface{}) { fataled = true }
|
|
|
|
|
|
|
|
|
|
|
|
logFatalf = func(s string, v ...interface{}) {
|
|
|
|
|
|
|
|
fataled = true
|
|
|
|
|
|
|
|
close(ch)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
logFatalf = origLogFatalf
|
|
|
|
logFatalf = origLogFatalf
|
|
|
|
}()
|
|
|
|
}()
|
|
|
@ -45,6 +51,7 @@ func Test_start_shouldFatalAfterTimeout_ifNotInitialized(t *testing.T) {
|
|
|
|
monitor := New(timeout, datastore, context.Background())
|
|
|
|
monitor := New(timeout, datastore, context.Background())
|
|
|
|
monitor.Start()
|
|
|
|
monitor.Start()
|
|
|
|
<-time.After(2 * timeout)
|
|
|
|
<-time.After(2 * timeout)
|
|
|
|
|
|
|
|
<-ch
|
|
|
|
|
|
|
|
|
|
|
|
assert.True(t, fataled, "monitor should been timeout and fatal")
|
|
|
|
assert.True(t, fataled, "monitor should been timeout and fatal")
|
|
|
|
}
|
|
|
|
}
|
|
|
|