test(13-06): cover the Phase 13 framework edges in surf, conga, lagoon and tide
- surf: a transitive three-route family, HEAD and sorted Allow on family paths, a family across two plugins with per-member middleware, refused trailing-slash and multi-segment shapes - conga: refusal messages name kind and queue, a configured queue counts as served, a delayed unregistered dispatch waits scheduled - lagoon: prohibited under a wildcard, on a dotted path and after bail - tide: quoted, RFC 5987 and multi-date download names; a captured id beside a masked notification id
This commit is contained in:
@@ -3,6 +3,7 @@ package conga
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -217,3 +218,45 @@ func TestUnregisteredKindWithoutWorker(t *testing.T) {
|
||||
t.Fatalf("river job = %+v, want available on default", row)
|
||||
}
|
||||
}
|
||||
|
||||
// TestUnregisteredKindRefusalAndDelay pins the edges of the workerless
|
||||
// path: the refusal names the kind and the queue (a configured queue is
|
||||
// served too, and nothing is written), and a delayed Dispatch of an
|
||||
// unregistered kind waits scheduled with its summer_jobs row.
|
||||
func TestUnregisteredKindRefusalAndDelay(t *testing.T) {
|
||||
db, dsn := migratedDB(t)
|
||||
app, gdb := testApp(t, db, dsn, map[string]any{"queue.queues": map[string]any{"acme_imports": 2}})
|
||||
m, err := From(app)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
startTestWorker(t, app, WorkerOptions{pollOnly: true, pollInterval: unregisteredPoll},
|
||||
Job(func(context.Context, acmeMailArgs) error { return nil }, OnQueue("acme_mail")))
|
||||
ctx := t.Context()
|
||||
jobs, records := countKind(t, gdb, "acme.pending_import"), countRecords(t, gdb)
|
||||
|
||||
_, err = m.Dispatch(ctx, gdb, acmePendingImportArgs{ImportID: 1}, DispatchOpts{Label: "acme.pending", Queue: "acme_imports"})
|
||||
if !errors.Is(err, ErrUnregisteredKindQueue) || !strings.Contains(err.Error(), `kind "acme.pending_import" on queue "acme_imports", which a worker serves`) {
|
||||
t.Fatalf("configured queue: err = %v", err)
|
||||
}
|
||||
err = m.Enqueue(ctx, gdb, acmePendingImportArgs{ImportID: 1}, EnqueueOpts{})
|
||||
if !errors.Is(err, ErrUnregisteredKindQueue) || !strings.Contains(err.Error(), `kind "acme.pending_import" names no queue`) {
|
||||
t.Fatalf("no queue: err = %v", err)
|
||||
}
|
||||
if countKind(t, gdb, "acme.pending_import") != jobs || countRecords(t, gdb) != records {
|
||||
t.Fatal("a refused insert wrote a row")
|
||||
}
|
||||
|
||||
id, err := m.Dispatch(ctx, gdb, acmePendingImportArgs{ImportID: 2}, DispatchOpts{Label: "acme.later", Queue: "acme_later", Delay: time.Hour})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rec := mustGet(t, m, id)
|
||||
if rec.Label != "acme.later" || rec.RiverJobID == nil {
|
||||
t.Fatalf("record = %+v", rec)
|
||||
}
|
||||
row := riverJob(t, gdb, *rec.RiverJobID)
|
||||
if row.State != "scheduled" || row.Queue != "acme_later" || row.Attempt != 0 {
|
||||
t.Fatalf("delayed unregistered job = %+v, want scheduled on acme_later", row)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user