MCPcopy
hub / github.com/robfig/cron / TestParseScheduleErrors

Function TestParseScheduleErrors

parser_test.go:121–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestParseScheduleErrors(t *testing.T) {
122 var tests = []struct{ expr, err string }{
123 {"* 5 j * * *", "failed to parse int from"},
124 {"@every Xm", "failed to parse duration"},
125 {"@unrecognized", "unrecognized descriptor"},
126 {"* * * *", "expected 5 to 6 fields"},
127 {"", "empty spec string"},
128 }
129 for _, c := range tests {
130 actual, err := secondParser.Parse(c.expr)
131 if err == nil || !strings.Contains(err.Error(), c.err) {
132 t.Errorf("%s => expected %v, got %v", c.expr, c.err, err)
133 }
134 if actual != nil {
135 t.Errorf("expected nil schedule on error, got %v", actual)
136 }
137 }
138}
139
140func TestParseSchedule(t *testing.T) {
141 tokyo, _ := time.LoadLocation("Asia/Tokyo")

Callers

nothing calls this directly

Calls 2

ParseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected