test(11-07): cover jobs, scheduler and lagoon seams branch by branch

- conga: TestOutcome*, TestCancelQueuedNeverRuns, TestCancelRunningCancelsCtx,
  TestStopJobFromWorker, TestManagerPHPSemantics, principal, delay,
  registration, worker and queue-setting branches; TestQueueClear and
  TestQueueWork move to commands_test.go with the batch/state and
  queue-filter cases (coverage 92.5%)
- scheduler: validation, ordering, missing catalog, log writer, dueAt
- lagoon: TestQueueMigrationsUpDown (River v7 + summer_jobs, rollback,
  idempotent rerun), OnDatabase isolation, Transaction edges
- bonfire TestCallEdges, pact TestCadence
This commit is contained in:
Jakub Zych
2026-09-30 14:14:21 +02:00
parent 6f50b6c940
commit 35ac96d664
10 changed files with 1705 additions and 432 deletions

View File

@@ -0,0 +1,49 @@
package pact
import (
"testing"
"time"
)
// TestCadence covers the schedule cadence constructors and accessors.
func TestCadence(t *testing.T) {
cases := []struct {
name string
c Cadence
zero bool
interval time.Duration
hour int
minute int
daily bool
}{
{"zero", Cadence{}, true, 0, 0, 0, false},
{"daily", Daily(), false, 24 * time.Hour, 0, 0, true},
{"daily_at", DailyAt(3, 45), false, 24 * time.Hour, 3, 45, true},
{"every", Every(5 * time.Minute), false, 5 * time.Minute, 0, 0, false},
{"every_zero", Every(0), false, 0, 0, 0, false},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if c.c.IsZero() != c.zero {
t.Errorf("IsZero = %v", c.c.IsZero())
}
if c.c.Interval() != c.interval {
t.Errorf("Interval = %s, want %s", c.c.Interval(), c.interval)
}
h, m, ok := c.c.At()
if ok != c.daily || h != c.hour || m != c.minute {
t.Errorf("At = %d:%d %v, want %d:%d %v", h, m, ok, c.hour, c.minute, c.daily)
}
})
}
var _ HasSchedule = scheduleOnly{}
if got := (scheduleOnly{}).Schedule(); len(got) != 1 || got[0].Command != "acme:prune" || got[0].Cadence != Daily() {
t.Fatalf("Schedule = %+v", got)
}
}
type scheduleOnly struct{}
func (scheduleOnly) Schedule() []ScheduledCommand {
return []ScheduledCommand{{Command: "acme:prune", Cadence: Daily()}}
}