ONE in-memory stand-in for the suspension table, and the transaction primitives around it.
It replaces FakeFrontierRepo, and is much smaller than it was: seven
query! clauses become four, and the ON CONFLICT merge — its trickiest and
most bug-prone part, where two of the three real SQL bugs lived — is simply
gone. Suspensions are append-only, so there is nothing to merge.
What this does NOT fix
It still pattern-matches SQL rather than executing it, so it cannot see a bug
INSIDE the SQL. That is test/real_postgres_suspension_test.exs's job, and
the reason that file exists: the first run of it caught a uuid-vs-text
parameter mismatch that failed every insert, which this fake would have
accepted happily.
Transactions are real here
transaction/2 and rollback/1 are implemented rather than absent, which
matters more than it sounds. Suspension.transaction/1 only wraps when the
repo exports transaction/2 — so a fake without it silently takes the
no-transaction path, and a test asserting anything about transaction
boundaries passes for the wrong reason.
Why this ships in lib/ rather than test/support/
Because it is for HOSTS, and Hex does not package test/support. A dependent
that wanted it had to hand-copy the file — which is exactly what makes a copy
drift, and one already did: the frontier's INSERT grew a column and the
copies broke three releases later, in a repo whose own tests had passed the
whole time.
Shipping it costs a module in the compiled artifact and removes a recurring failure mode for every dependent. It has no runtime callers and pulls in nothing.
Use
setup do
start_supervised!(ReactiveDag.Test.FakeSuspensionRepo)
ReactiveDag.Test.FakeSuspensionRepo.install()
end
Summary
Functions
Whether anything is suspended.
Whether the calling process is inside a fake transaction.
Point the library's repo at this fake for the duration of the test.
Suspensions as {waiting, resource, row_uuid}, sorted — the usual assertion.
Every suspension recorded, oldest first.
Drop everything — for a test wanting a known-empty state mid-run.
A real transaction, flagging the process while inside.
The distinct resources with work suspended.
Functions
Whether anything is suspended.
Whether the calling process is inside a fake transaction.
Point the library's repo at this fake for the duration of the test.
Suspensions as {waiting, resource, row_uuid}, sorted — the usual assertion.
Every suspension recorded, oldest first.
Drop everything — for a test wanting a known-empty state mid-run.
A real transaction, flagging the process while inside.
The flag is what lets a test assert that expensive work runs with NOTHING open — the property the whole redesign exists for, and one that cannot be checked against a repo that has no transactions at all.
The distinct resources with work suspended.