restart_interval_test.go 507 Bytes
Newer Older
“李磊”'s avatar
“李磊” committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
}