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

Function TestNextWithTz

spec_test.go:248–273  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

246}
247
248func TestNextWithTz(t *testing.T) {
249 runs := []struct {
250 time, spec string
251 expected string
252 }{
253 // Failing tests
254 {"2016-01-03T13:09:03+0530", "14 14 * * *", "2016-01-03T14:14:00+0530"},
255 {"2016-01-03T04:09:03+0530", "14 14 * * ?", "2016-01-03T14:14:00+0530"},
256
257 // Passing tests
258 {"2016-01-03T14:09:03+0530", "14 14 * * *", "2016-01-03T14:14:00+0530"},
259 {"2016-01-03T14:00:00+0530", "14 14 * * ?", "2016-01-03T14:14:00+0530"},
260 }
261 for _, c := range runs {
262 sched, err := ParseStandard(c.spec)
263 if err != nil {
264 t.Error(err)
265 continue
266 }
267 actual := sched.Next(getTimeTZ(c.time))
268 expected := getTimeTZ(c.expected)
269 if !actual.Equal(expected) {
270 t.Errorf("%s, \"%s\": (expected) %v != %v (actual)", c.time, c.spec, expected, actual)
271 }
272 }
273}
274
275func getTimeTZ(value string) time.Time {
276 if value == "" {

Callers

nothing calls this directly

Calls 4

ParseStandardFunction · 0.85
getTimeTZFunction · 0.85
ErrorMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected