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

@@ -275,3 +275,43 @@ func TestTransactionAfterCommit(t *testing.T) {
}
})
}
// TestTransactionEdges covers the argument edges of Transaction and
// AfterCommit.
func TestTransactionEdges(t *testing.T) {
if err := Transaction(context.Background(), nil, func(context.Context, *gorm.DB) error { return nil }); err == nil {
t.Fatal("Transaction accepted a nil handle")
}
AfterCommit(context.Background(), nil, nil) // a nil fn is a no-op
ran := false
AfterCommit(nil, nil, func(ctx context.Context, db *gorm.DB) {
if ctx == nil || db != nil {
t.Error("nil ctx and handle were not normalized")
}
ran = true
})
if !ran {
t.Fatal("AfterCommit without a handle did not run immediately")
}
if cleanHandle(nil, context.Background()) != nil {
t.Fatal("cleanHandle(nil) is not nil")
}
db, _ := dedicatedDB(t, "lagoon_after_commit_edges")
gdb, err := Use(t.Context(), db)
if err != nil {
t.Fatal(err)
}
var got context.Context
if err := Transaction(nil, gdb, func(ctx context.Context, tx *gorm.DB) error {
AfterCommit(ctx, tx, func(ctx context.Context, _ *gorm.DB) { got = ctx })
return nil
}); err != nil {
t.Fatal(err)
}
if got == nil {
t.Fatal("callback of a Transaction with a nil ctx did not run with a context")
}
if err := registerAfterCommit(gdb); err != nil {
t.Fatalf("registering the after-commit callback twice: %v", err)
}
}