test.contract_refused
A contract run sent nothing to the provider's sandbox, because a connection it goes through has nothing set, or nothing valid, for its credential or address, or its environment chooses live.
Area 14, Tools; not declinable; the next step is usually the human's.
Why Jadpo refuses it
jadpo test --kind contract runs the tests that reach a provider
against its sandbox: each call a test's fakes: doesn't script goes
through the connection, with the credential, environment and address
jadpo dev reads, from the environment and then .env.local. It is
the run that shows the provider still answers as the package's types
say, so it has to reach the real sandbox with a real key.
A connection whose environment chooses live would send the tests'
calls to the provider's live API, where a call can cost money or change
real data, and a connection with nothing set would send a stand-in key,
whose refusal proves nothing. So the run checks every connection it
goes through before it sends anything. Jadpo won't choose the
environment or set a key for you: which of your accounts at the
provider the calls reach is yours to decide.
What it looks like
A courier desk tracks parcels through its own integration with Acme Couriers, and one test reaches it:
config.jadpo:
config { couriers_api_key: Text { secret: true } couriers_environment: ProviderEnvironment { default: ProviderEnvironment.sandbox }}
app.jadpo:
application { connections: { couriers: { package: AcmeCouriers.v1 domains: [shipping] credential: config.couriers_api_key environment: config.couriers_environment } }}
domains/shipping/actions/track_parcel.test.jadpo:
use shared/providers/acme_courierstest "a parcel's status comes back" { var lookup: AcmeCouriers.ParcelLookup = AcmeCouriers.ParcelLookup { parcel_id: "P1" } var parcel: AcmeCouriers.Parcel = track_parcel(lookup) assert parcel.status != ""}
Nothing on this machine sets COURIERS_API_KEY, so the run is refused
before anything is sent:
jadpo test --kind contract error couriers has nothing set for the provider's sandbox
- reason
- A contract run sends its cases' calls through
couriersto the provider's sandbox, with the settingsjadpo devreads, and nothing setsCOURIERS_API_KEY, so only a stand-in would be sent. - next
- Set
COURIERS_API_KEYin.env.local, or in the job's environment, for the sandbox, then run it again (human) - rule
- test.
contract_ refused - help
- https://jadpo.
dev/docs/errors/test. contract_ refused
(human) at the end of the next: line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides which of your accounts at Acme the tests' calls are made with.
A connection whose environment chooses live is refused too, whatever
else is set:
printf 'COURIERS_API_KEY=sandbox_key\nCOURIERS_ENVIRONMENT=live\n' > .env.localjadpo test --kind contract
error couriers's environment is live
- reason
- A contract run sends its cases' calls to the provider's sandbox, never its live API, and
COURIERS_ENVIRONMENTchooseslive. - next
- Set
COURIERS_ENVIRONMENTtosandboxfor the run, then run it again (human) - rule
- test.
contract_ refused - help
- https://jadpo.
dev/docs/errors/test. contract_ refused
How to fix it
If the run should reach Acme's sandbox, set the sandbox's key, and choose the sandbox, where you run it:
jadpo config set couriers_api_keyjadpo test --kind contract
jadpo config set asks for the key without showing what you type and
saves it in .env.local, which is never committed. In a scheduled job,
give COURIERS_API_KEY from the job's secrets and
COURIERS_ENVIRONMENT=sandbox. The test's call then goes to
https://sandbox.acme-couriers.example.
If you meant to run the tests without reaching Acme, leave out
--kind contract:
jadpo testEvery provider call is then answered by its package's fake, and nothing leaves your machine.
Related
Markdown for agents: /docs/errors/test.contract_refused.md.Built from Jadpo's main branch at commit 9080dc3.