package monitor_daemon import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestIsNeedStart(t *testing.T) { r := newRestartInterval() r.config.incr = time.Second r.setLastStart() assert.Equal(t, r.isNeedStart(), false) time.Sleep(time.Second) assert.Equal(t, r.isNeedStart(), false) r.config.maxInterval = time.Second r.setLastStart() assert.Equal(t, r.isNeedStart(), false) time.Sleep(time.Second) t.Log(r) assert.Equal(t, r.isNeedStart(), true) }