Mediate.Conformance.AdapterCase (mediate_conformance v0.1.0)

Copy Markdown View Source

The Tier 1 case template. use Mediate.Conformance.AdapterCase, adapter: Mediate.Rbac, repo: Example.Infrastructure.Repo, world: Example.World defines a test module. Its setup prepares the repo for the test, stubs the clock, and binds the adapter through the configuration override. So each adapter's conformance run is its own module in its own package, and each package's suite is its own OS process. Every adapter in this repository passes async: false, sandbox:, setup_queries:, committed:, and versions:. Cerbos, OpenFGA, and Postgres pass outage:, and OpenFGA passes seed:.

The template names no schema and no rule. world: is a Mediate.Conformance.World. That module says what a population holds, what the rule over it allows, and how to write one through the seam. An adapter outside this repository points the template at its own tables and runs the same laws.

The tests are the laws under "The laws" in the conformance document. The name of each is its id and its sentence from Mediate.Conformance.Law. The bodies live in Mediate.Conformance.AdapterCase.Laws and its modules. The scope cap declaration and the fact-write shape sit beside them.

Three laws are properties over Mediate.Conformance.Gen. Each iteration writes a population through the seam. When the adapter keeps state of its own, the iteration seeds that state through the seed: module. The fail-closed law needs outage:. The latency law needs committed:. The change-management laws need versions: and committed: both.

Options:

  • adapter: the adapter module, required.
  • repo: the mediated repo the template writes the population through, required.
  • world: the Mediate.Conformance.World module, required.
  • sandbox: a module that answers setup(repo, tags). The template calls it first in every test. It is for a suite whose repo needs a checkout, a transaction, or a row of its own before the test runs. Omit it for a repo that needs none.
  • async: default true, and false when the test gives committed:. The committed cases truncate tables every module shares.
  • seed: a Mediate.Conformance.Seed module. The template calls it after every population it writes. Omit it for an adapter that reads the world's own tables.
  • outage: a module whose outage/0 makes the engine unreachable for the rest of the test. ac3-05 exists only when given.
  • setup_queries: the queries the adapter adds to every mediated call. The shape laws count them. Default 0.
  • committed: [repo: module, owner: module, tables: [name]], the committed and owner repos and the tables to truncate. ac2-05 exists only when given.
  • versions: a Mediate.Conformance.Versions module. The cm3 laws run when given. When not, they skip and print the reason. They write on the committed repo, so committed: must come with it.