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

Function TestStandardSpecSchedule

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

Source from the content-addressed store, hash-verified

313}
314
315func TestStandardSpecSchedule(t *testing.T) {
316 entries := []struct {
317 expr string
318 expected Schedule
319 err string
320 }{
321 {
322 expr: "5 * * * *",
323 expected: &SpecSchedule{1 << seconds.min, 1 << 5, all(hours), all(dom), all(months), all(dow), time.Local},
324 },
325 {
326 expr: "@every 5m",
327 expected: ConstantDelaySchedule{time.Duration(5) * time.Minute},
328 },
329 {
330 expr: "5 j * * *",
331 err: "failed to parse int from",
332 },
333 {
334 expr: "* * * *",
335 err: "expected exactly 5 fields",
336 },
337 }
338
339 for _, c := range entries {
340 actual, err := ParseStandard(c.expr)
341 if len(c.err) != 0 && (err == nil || !strings.Contains(err.Error(), c.err)) {
342 t.Errorf("%s => expected %v, got %v", c.expr, c.err, err)
343 }
344 if len(c.err) == 0 && err != nil {
345 t.Errorf("%s => unexpected error %v", c.expr, err)
346 }
347 if !reflect.DeepEqual(actual, c.expected) {
348 t.Errorf("%s => expected %b, got %b", c.expr, c.expected, actual)
349 }
350 }
351}
352
353func TestNoDescriptorParser(t *testing.T) {
354 parser := NewParser(Minute | Hour)

Callers

nothing calls this directly

Calls 3

allFunction · 0.85
ParseStandardFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected