ErrorsExternal services · rule
test.contract_uncovered
No case of a contract run sent the provider's sandbox an operation the app calls that was written from the provider's documentation and that no recording confirms.
Area 11, External services; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
An operation written from the provider's documentation,
source: PackageSource.written, is only as right as the reading of
those pages. Until a real answer has been checked against it, by a
recording jadpo package record keeps, nothing shows the provider
answers it as its types say. Every build allows it, and the contract
run, jadpo test --kind contract, is where it is checked: each such
operation the app calls needs a case that sends it to the sandbox.
A test that scripts the operation's answer in its fakes: reaches it,
but its call never leaves the machine, so it checks the code around the
call and not the operation. A run where no case sent the operation would
pass while the provider could be answering something else entirely.
What it looks like
A courier desk tracks parcels through its own integration with Acme
Couriers, written from Acme's documentation, with no recording of
parcels.get. Its one test scripts the answer:
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 app { couriers }use shared/providers/acme_courierstest "a delivered parcel says so" { fakes: { couriers.parcels.get: [ AcmeCouriers.Parcel { status: "delivered" } ] } var lookup: AcmeCouriers.ParcelLookup = AcmeCouriers.ParcelLookup { parcel_id: "P1" } var parcel: AcmeCouriers.Parcel = track_parcel(lookup) assert parcel.status == "delivered"}
The run's one case scripts parcels.get, so nothing goes to the
sandbox, and the run fails:
echo 'COURIERS_API_KEY=sandbox_key' > .env.localjadpo test --kind contract
error couriers.parcels.get has no contract case
--> shared/providers/acme_couriers/v1/resources/parcels.jadpo:2:5
|2 | get: { | ^^^ no case sent it to the sandbox
- reason
- It was written from the provider's documentation and no recording confirms it, so a contract run is what checks it against the provider, and none of its cases sent it to the sandbox: no case reaches it, or each that does scripts its answer.
- next
- Write a test that reaches
couriers.parcels.getwith nofakes:answer for it, or confirm it withjadpo package record couriers parcels.get(agent) - rule
- test.
contract_ uncovered - help
- https://jadpo.
dev/docs/errors/test. contract_ uncovered
(agent) at the end of the next: line means your coding agent can
make the fix itself.
How to fix it
If you can call Acme's sandbox now, record the operation, which confirms it:
jadpo package record couriers parcels.get --input '{"parcel_id": "P1"}'The answer is checked against Parcel and kept as
shared/providers/acme_couriers/v1/recordings/parcels.get.json, and the
next contract run needs no case for parcels.get.
If the run should check it each time, add a test that reaches
parcels.get with no fakes: answer for it:
test "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 != ""}
In jadpo test its call is answered by the package's fake; in the
contract run it goes to Acme's sandbox, and the run passes once the
answer decodes as a Parcel.
Related
Markdown for agents: /docs/errors/test.contract_uncovered.md.Built from Jadpo's main branch at commit 9080dc3.