The database side of a resource package's own tests, with no proxy around.
In test/test_helper.exs:
Alternera.Resource.Test.start_database!(Finance.Resources)
ExUnit.start()start_database!/2 creates the test database when it is missing, starts
Alternera.Resource.Repo on it, runs the package's migrations and
puts the repo's sandbox in manual mode. Configure
the repo in the package's config/test.exs:
config :alternera_resource_sdk, Alternera.Resource.Repo,
database: "finance_test",
pool: Ecto.Adapters.SQL.Sandbox,
priv: "priv/resource_repo"The contract kit (Alternera.Resource.Test.Contract) and tests of
the package's own check out the sandbox with checkout/1 and make tenant
ids with create_tenant!/0.
Summary
Functions
Checks out a sandbox connection for the test; shared unless the test is async.
A stand-in tenant id. Resource tables have no foreign key to a tenants table, so a tenant is only an id here.
Prepares the test database for the package of domain. :priv is the
directory that holds the package's migrations (default
"priv/resource_repo", relative to the package project).
Functions
@spec checkout(map()) :: :ok
Checks out a sandbox connection for the test; shared unless the test is async.
@spec create_tenant!() :: String.t()
A stand-in tenant id. Resource tables have no foreign key to a tenants table, so a tenant is only an id here.
Prepares the test database for the package of domain. :priv is the
directory that holds the package's migrations (default
"priv/resource_repo", relative to the package project).