# `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](/docs/external-services.md); 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:

```jadpo
config {
    couriers_api_key: Text {
        secret: true
    }
    couriers_environment: ProviderEnvironment {
        default: ProviderEnvironment.sandbox
    }
}
```






app.jadpo:

```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:

```jadpo
use app { couriers }
use shared/providers/acme_couriers

test "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:

```sh
echo 'COURIERS_API_KEY=sandbox_key' > .env.local
jadpo test --kind contract
```

```text
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.get` with no `fakes:` answer for it, or confirm it with `jadpo package record couriers parcels.get` (agent)
  rule: test.contract_uncovered
  help: https://jadpo.dev/docs/errors/test.contract_uncovered

test failed: contract run failed, 1 contract case, 1 operation with no case
```

`(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:

```sh
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:

```jadpo
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

- [Tests and fakes](/docs/tests-and-fakes.md)
- [Provenance and confirmation](/docs/where-packages-come-from.md#provenance-and-confirmation)
- [`jadpo package record`](/docs/commands-for-packages.md#jadpo-package-record)
- [Fakes for integrations](/docs/fakes-for-integrations.md)
