package cron import ( "testing" "time" "haixun-backend/internal/library/clock" ) func TestNextRunAt_HourlyCron(t *testing.T) { from := time.Date(2026, 6, 23, 10, 30, 0, 0, time.UTC) next, err := NextRunAt("0 * * * *", "UTC", from) if err != nil { t.Fatalf("NextRunAt() error = %v", err) } nextTime := clock.FromUnixNano(next) if nextTime.Hour() != 11 || nextTime.Minute() != 0 { t.Fatalf("next = %v, want 11:00 UTC", nextTime) } } func TestNextRunAt_InvalidCron(t *testing.T) { _, err := NextRunAt("not-a-cron", "UTC", clock.Now()) if err == nil { t.Fatal("expected invalid cron error") } }