forked from robfig/cron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendofmonth_test.go
30 lines (27 loc) · 1005 Bytes
/
endofmonth_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
package cron
import (
"testing"
"time"
)
func TestEomNext(t *testing.T) {
tests := []struct {
time time.Time
expected time.Time
}{
{time.Date(2019, time.January, 20, 0, 0, 0, 0, time.Local), time.Date(2019, time.January, 31, 0, 0, 0, 0, time.Local)},
{time.Date(2019, time.January, 31, 0, 0, 0, 0, time.Local), time.Date(2019, time.February, 28, 0, 0, 0, 0, time.Local)},
{time.Date(2019, time.December, 31, 1, 12, 31, 312, time.Local), time.Date(2020, time.January, 31, 0, 0, 0, 0, time.Local)},
{time.Date(2019, time.May, 31, 1, 12, 31, 312, time.Local), time.Date(2019, time.June, 30, 0, 0, 0, 0, time.Local)},
{time.Date(2020, time.February, 13, 1, 12, 49, 312, time.Local), time.Date(2020, time.February, 29, 0, 0, 0, 0, time.Local)},
}
for _, c := range tests {
testSchedule := EomSchedule{
time.Local,
}
actual := testSchedule.Next(c.time)
expected := c.expected
if actual != expected {
t.Errorf("(expected) %v != %v (actual)", expected, actual)
}
}
}