The contract test kit for a resource package, run with no proxy around.
defmodule Finance.ContractTest do
use Alternera.Resource.Test.Contract
resource_package_contract Finance.Resources,
samples: %{Finance.Currency => %{code: "SEK"}}
endFor each resource of the domain it generates tests that:
- check every rule of
Alternera.Resource.Verifierson the compiled resource; - (once per package) refuse a migration that drops functions, as the
down ash.codegenwrites for the extensions migration does: on the proxy's database Ash's functions are the proxy's too; - find a migration that creates its table and its versions table in the
package's schema with an index on
tenant_id, and a snapshot of each under the snapshots directory; - create, read, update and destroy a record in two stand-in tenants and find each tenant's record only in that tenant;
- find a version row for each write, carrying the actor's id;
- with
cacheon, tell the host of each committed write; without it, tell it nothing; - refuse writes to an actor without
tenant_admin, and reads when the host is not licensed (a destroy still works then); - refuse, as an error on the reference's field, a create or an update
whose
belongs_tonames a record of another tenant.
It also checks the package's page of the user guide, when the domain has
one (docs:): its front matter has title, section: Resource packages,
order, summary and verified, and no licensed.
Options: :samples (see Alternera.Resource.Test.Samples),
:priv (the directory holding migrations, default
"priv/resource_repo") and :snapshots (default
"priv/resource_snapshots"). The test database comes from
Alternera.Resource.Test.start_database!/2 in test_helper.exs.
Summary
Functions
Generates the contract tests for every resource of domain.