Skip to content

Builds the conformance input-log fixture inside its cases - #90

Merged
johnnyt merged 1 commit into
mainfrom
sp-flj-lazy-input-log-fixture
Sep 8, 2026
Merged

Builds the conformance input-log fixture inside its cases#90
johnnyt merged 1 commit into
mainfrom
sp-flj-lazy-input-log-fixture

Conversation

@johnnyt

@johnnyt johnnyt commented Sep 8, 2026

Copy link
Copy Markdown
Member

What

StatifierPersistence.Testing.StorageConformance registered a setup that
inserted the input-log fixture run. ExUnit runs setup callbacks in
definition order and the template's are defined where a host writes use,
so a host whose adapter needs a per-test binding established before any
write - a session parameter, a connection-scoped setting, a sandbox
checkout - found a row already written by the time its own callback ran,
with nothing in the docs saying why or what to do instead.

Both halves of sp-flj:

  1. The fixture is lazy. input_log_run/2 is called inside each of the
    three cases that need it, rather than from a setup. The only callback
    the template registers now opens a handle and, where the adapter exports
    isolate/1, isolates it - it writes nothing.
  2. The moduledoc states the contract. A setup a host needs before any
    write goes above the use; a setup written below it is guaranteed
    only that no row has been written yet, not that nothing has run. The
    worked example is in the moduledoc.

The test

StatifierPersistence.Storage.SetupOrderingConformanceTest is the
host-shaped case: a setup defined deliberately BELOW the use, so it
runs after every callback the template registers, asserting the handle is
open (the template's setup ran first) and the input-log fixture run is
absent. Registered for the whole module, so the assertion holds over every
case the template generates for the input-log adapter, not over one.

Both new declarations carry a # sabotage: note, and both mutations were
run:

  • restoring the eager setup in the template -> 38 of 38 cases in the
    new module red, the fixture run already inserted when the host-shaped
    callback ran;
  • dropping Storage.insert_run/4 from input_log_run/2 -> 5 cases
    red, reporting :run_not_found where a run was expected.

Both reverted from a copy taken before the edit; the gate is green on the
reverted tree.

Verification

  • Full mix quality green on this HEAD: format, compile (warnings as
    errors), credo, dialyzer, deps, 520 of 520 tests, 95.7% coverage.
    mix quality.verify attests the run (scope all, no profile).
  • The input-log cases pass on both adapters: InputLogConformanceTest
    (in-memory) and EctoConformanceTest (real Postgres) run green, and a
    --trace run shows the input-log case names still generated under the
    Ecto adapter.
  • Only one setup remains in the template (the use-registered one at
    storage_conformance.ex), and its body is Storage.new/2 plus the
    optional isolate/1.

Provenance

No file outside the bead's map was touched. changelog.d/sp-flj.md under
Fixed: the template ships in lib/ and is public surface an adapter
package binds against, so the ordering change is visible to someone who
only uses the public API.

Refs: sp-flj

The conformance template registered a `setup` that inserted the
input-log fixture run. ExUnit runs `setup` callbacks in definition
order and the template's are defined where a host writes `use`, so a
host whose adapter needs a per-test binding established before any
write - a session parameter, a connection-scoped setting, a sandbox
checkout - found a row already written by the time its own callback
ran, with nothing in the docs telling it why or what to do.

`input_log_run/2` is now called inside each of the three cases that
need the fixture, so the only callback the template registers opens a
handle and, where the adapter exports `isolate/1`, isolates it. It
writes nothing. The moduledoc states the contract that follows: a
setup a host needs before any write goes above the `use`, and one
written below is guaranteed only that no row has been written yet -
not that nothing has run.

`StatifierPersistence.Storage.SetupOrderingConformanceTest` is the
host-shaped case that holds both halves: a `setup` below the `use`
that asserts the handle is open and the fixture run absent, over every
case the template generates for the input-log adapter.

Refs: sp-flj
@johnnyt
johnnyt merged commit fb5f4a4 into main Sep 8, 2026
1 check passed
@johnnyt
johnnyt deleted the sp-flj-lazy-input-log-fixture branch September 8, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant