Test that the cron is run in the local time zone (as opposed to UTC).
(t *testing.T)
| 295 | |
| 296 | // Test that the cron is run in the local time zone (as opposed to UTC). |
| 297 | func TestLocalTimezone(t *testing.T) { |
| 298 | wg := &sync.WaitGroup{} |
| 299 | wg.Add(2) |
| 300 | |
| 301 | now := time.Now() |
| 302 | // FIX: Issue #205 |
| 303 | // This calculation doesn't work in seconds 58 or 59. |
| 304 | // Take the easy way out and sleep. |
| 305 | if now.Second() >= 58 { |
| 306 | time.Sleep(2 * time.Second) |
| 307 | now = time.Now() |
| 308 | } |
| 309 | spec := fmt.Sprintf("%d,%d %d %d %d %d ?", |
| 310 | now.Second()+1, now.Second()+2, now.Minute(), now.Hour(), now.Day(), now.Month()) |
| 311 | |
| 312 | cron := newWithSeconds() |
| 313 | cron.AddFunc(spec, func() { wg.Done() }) |
| 314 | cron.Start() |
| 315 | defer cron.Stop() |
| 316 | |
| 317 | select { |
| 318 | case <-time.After(OneSecond * 2): |
| 319 | t.Error("expected job fires 2 times") |
| 320 | case <-wait(wg): |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | // Test that the cron is run in the given time zone (as opposed to local). |
| 325 | func TestNonLocalTimezone(t *testing.T) { |