-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduler_test.go
69 lines (61 loc) · 1.89 KB
/
scheduler_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"github.com/amundi/escheck.v2/config"
"github.com/amundi/escheck.v2/eslog"
"github.com/stretchr/testify/assert"
"testing"
)
func Test_Scheduler(t *testing.T) {
sched := new(scheduler)
eslog.InitSilent()
info := &config.Query{
Schedule: "500s",
Alert_onlyonce: true,
Alert_endmsg: true,
}
sched.initScheduler(info)
assert.Equal(t, true, sched.isAlertOnlyOnce)
assert.Equal(t, true, sched.isAlertEndMsg)
assert.Equal(t, "8m20s", sched.waitSchedule.String())
info = &config.Query{
Schedule: "30m",
Alert_onlyonce: false,
Alert_endmsg: false,
}
sched.initScheduler(info)
assert.Equal(t, false, sched.isAlertOnlyOnce)
assert.Equal(t, false, sched.isAlertEndMsg)
assert.Equal(t, "30m0s", sched.waitSchedule.String())
info = &config.Query{
Alert_onlyonce: false,
}
sched.initScheduler(info)
assert.Equal(t, true, sched.isAlertOnlyOnce)
assert.Equal(t, false, sched.isAlertEndMsg)
assert.Equal(t, "10m0s", sched.waitSchedule.String())
assert.Equal(t, "10m0s", sched.alertSchedule.String())
info = &config.Query{}
sched.initScheduler(info)
assert.Equal(t, true, sched.isAlertOnlyOnce)
assert.Equal(t, false, sched.isAlertEndMsg)
assert.Equal(t, "10m0s", sched.waitSchedule.String())
assert.Equal(t, "10m0s", sched.alertSchedule.String())
info = &config.Query{
Schedule: "pouet",
Alert_onlyonce: false,
}
sched.initScheduler(info)
assert.Equal(t, true, sched.isAlertOnlyOnce)
assert.Equal(t, false, sched.isAlertEndMsg)
assert.Equal(t, "10m0s", sched.waitSchedule.String())
assert.Equal(t, "10m0s", sched.alertSchedule.String())
info = &config.Query{
Schedule: "40z",
Alert_onlyonce: false,
}
assert.Equal(t, true, sched.isAlertOnlyOnce)
assert.Equal(t, false, sched.isAlertEndMsg)
assert.Equal(t, "10m0s", sched.waitSchedule.String())
assert.Equal(t, "10m0s", sched.alertSchedule.String())
sched.initScheduler(info)
}