Update gcron_schedule_test.go

add test to slash template parse
This commit is contained in:
kingeasternsun
2021-08-26 10:58:54 +08:00
committed by GitHub
parent c7b379e53f
commit b9a07b104a

View File

@ -4,8 +4,33 @@ import (
"strings"
"testing"
"time"
"github.com/gogf/gf/test/gtest"
)
func TestSlash(t *testing.T) {
runs := []struct {
spec string
expected map[int]struct{}
}{
{"0 0 0 * Feb Mon/2", map[int]struct{}{1: struct{}{}, 3: struct{}{}, 5: struct{}{}}},
{"0 0 0 * Feb *", map[int]struct{}{1: struct{}{}, 2: struct{}{}, 3: struct{}{}, 4: struct{}{}, 5: struct{}{}, 6: struct{}{}, 0: struct{}{}}},
}
gtest.C(t, func(t *gtest.T) {
for _, c := range runs {
sched, err := newSchedule(c.spec)
if err != nil {
t.Fatal(err)
}
t.AssertEQ(sched.week, c.expected)
}
})
}
func TestNext(t *testing.T) {
runs := []struct {
time, spec string