Builds the conformance input-log fixture inside its cases - #90
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
StatifierPersistence.Testing.StorageConformanceregistered asetupthatinserted the input-log fixture run. ExUnit runs
setupcallbacks indefinition 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:
input_log_run/2is called inside each of thethree cases that need it, rather than from a
setup. The only callbackthe template registers now opens a handle and, where the adapter exports
isolate/1, isolates it - it writes nothing.write goes above the
use; a setup written below it is guaranteedonly that no row has been written yet, not that nothing has run. The
worked example is in the moduledoc.
The test
StatifierPersistence.Storage.SetupOrderingConformanceTestis thehost-shaped case: a
setupdefined deliberately BELOW theuse, so itruns 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 wererun:
setupin the template -> 38 of 38 cases in thenew module red, the fixture run already inserted when the host-shaped
callback ran;
Storage.insert_run/4frominput_log_run/2-> 5 casesred, reporting
:run_not_foundwhere a run was expected.Both reverted from a copy taken before the edit; the gate is green on the
reverted tree.
Verification
mix qualitygreen on this HEAD: format, compile (warnings aserrors), credo, dialyzer, deps, 520 of 520 tests, 95.7% coverage.
mix quality.verifyattests the run (scope all, no profile).InputLogConformanceTest(in-memory) and
EctoConformanceTest(real Postgres) run green, and a--tracerun shows the input-log case names still generated under theEcto adapter.
setupremains in the template (theuse-registered one atstorage_conformance.ex), and its body isStorage.new/2plus theoptional
isolate/1.Provenance
No file outside the bead's map was touched.
changelog.d/sp-flj.mdunderFixed: the template ships inlib/and is public surface an adapterpackage binds against, so the ordering change is visible to someone who
only uses the public API.
Refs: sp-flj