Skip to content

Commit

Permalink
New unit tests to demonstrate bug
Browse files Browse the repository at this point in the history
Output from go test before:
```
--- FAIL: TestNextTickAfter (0.01s)
    --- FAIL: TestNextTickAfter/next_run_after (0.01s)
        --- FAIL: TestNextTickAfter/next_run_after/next_run_after_excl_#63:_0_0_*_*_1#1 (0.00s)
            next_test.go:66: [0 0 * * 1#1][2009-11-23 00:00:00] expected 2009-12-07 00:00:00, got 2010-01-04 00:00:00
```

Now it all passes
  • Loading branch information
philodavies committed Jul 27, 2023
1 parent 5a6b134 commit ec435a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gronx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ func testcases() []Case {
{"* * * * 5#2", "2011-07-01 00:00:00", false, "2011-07-08 00:00:00"},
{"* * * * 5#1", "2011-07-01 00:00:00", true, "2011-07-01 00:01:00"},
{"* * * * 3#4", "2011-07-01 00:00:00", false, "2011-07-27 00:00:00"},
{"0 0 * * 1#1", "2009-10-23 00:00:00", false, "2009-11-02 00:00:00"},
{"0 0 * * 1#1", "2009-11-23 00:00:00", false, "2009-12-07 00:00:00"},
{"5/0 * * * *", "2021-04-19 12:54:00", false, "2018-08-13 00:25:00"},
{"5/20 * * * *", "2018-08-13 00:24:00", false, "2018-08-13 00:25:00"},
{"5/20 * * * *", "2018-08-13 00:45:00", true, "2018-08-13 01:05:00"},
Expand Down
2 changes: 1 addition & 1 deletion validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ func isValidWeekDay(val string, last int, ref time.Time) (bool, error) {
return false, nil
}

return ref.Day()/7 == nth-1, nil
return (ref.Day()-1)/7 == nth-1, nil
}

0 comments on commit ec435a0

Please sign in to comment.