forked from robfig/cron
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Description
Most tests use mock time, but integration tests with real time would catch timing-related bugs.
Current Approach
Tests use mock clocks for deterministic results:
c := newWithSeconds()
c.clock = clockwork.NewFakeClockAt(time.Now())Recommended Addition
// integration_test.go (with build tag)
// +build integration
func TestRealTimeScheduling(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
c := cron.New()
c.Start()
defer c.Stop()
executed := make(chan struct{})
c.AddFunc("@every 2s", func() {
close(executed)
})
select {
case <-executed:
// Success
case <-time.After(5 * time.Second):
t.Fatal("job not executed within expected time")
}
}Benefits
- Catch real-world timing issues
- Verify actual system clock behavior
- Test DST transitions (when they occur)
- Validate in CI environments
Severity
🟢 Low - Testing improvement
Found By
Pre-1.0 release code review with Zen/Gemini