forked from distribworks/dkron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix simple scheduling (distribworks#138)
- Loading branch information
Victor Castell
committed
Jun 4, 2016
1 parent
3e460e7
commit fa71979
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cron | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestSimpleNext(t *testing.T) { | ||
tests := []struct { | ||
time string | ||
date string | ||
expected string | ||
}{ | ||
// Simple cases | ||
{"2012-07-09T14:45:00Z", "2012-07-09T15:00:00Z", "2012-07-09T15:00:00Z"}, | ||
{"2012-07-09T14:45:00Z", "2012-07-05T13:00:00Z", "2022-07-09T14:45:00Z"}, | ||
} | ||
|
||
for _, c := range tests { | ||
now, _ := time.Parse(time.RFC3339, c.time) | ||
date, _ := time.Parse(time.RFC3339, c.date) | ||
actual := At(date).Next(now) | ||
expected, _ := time.Parse(time.RFC3339, c.expected) | ||
|
||
if !actual.After(now) { | ||
t.Errorf("%s, \"%s\": (expected) %v after %v (actual)", c.time, c.date, expected, actual) | ||
} | ||
|
||
if actual != expected { | ||
t.Errorf("%s, \"%s\": (expected) %v != %v (actual)", c.time, c.date, expected, actual) | ||
} | ||
} | ||
} |