Files
creator-hub/internal/creator/scheduler_test.go
T

32 lines
850 B
Go

package creator
import (
"testing"
"time"
)
func TestFixedScheduleUsesDueBoundary(t *testing.T) {
now := time.Date(2026, 4, 1, 12, 0, 0, 0, time.UTC)
last := now.Add(-time.Hour)
if !IsDue(last, now, time.Hour) || IsDue(last.Add(time.Minute), now, time.Hour) {
t.Fatal("schedule due check must include the exact boundary")
}
if got := NextFixedRun(last, now, time.Hour); !got.Equal(now) {
t.Fatalf("next fixed run = %s", got)
}
if got := NextFixedRun(time.Time{}, now, time.Hour); !got.Equal(now) {
t.Fatalf("first fixed run = %s", got)
}
}
func TestMetricDuePreservesUnavailableState(t *testing.T) {
now := time.Now().UTC()
if MetricDue(Work{}, now) {
t.Fatal("missing metric schedule is not due")
}
past := now.Add(-time.Minute)
if !MetricDue(Work{NextMetricAt: &past}, now) {
t.Fatal("past metric schedule is due")
}
}