(t *testing.T)
| 313 | } |
| 314 | |
| 315 | func 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 | |
| 353 | func TestNoDescriptorParser(t *testing.T) { |
| 354 | parser := NewParser(Minute | Hour) |
nothing calls this directly
no test coverage detected