# Bidder fixture tests in CI

The files from the tutorial at https://rtblint.org/learn/test-a-bidder-in-ci/.

They replay recorded bid requests against a running bidder and check every
answer with the RTBlint CLI. Bids are validated against the request that
produced them.

## Layout

Copy these into the root of your bidder repository:

```
bidder-fixtures.yml        -> .github/workflows/bidder-fixtures.yml
scripts/test-bidder.sh
fixtures/
  bid/                     valid requests the bidder must bid on (expect 200)
  no-bid/                  valid requests the bidder must pass on (expect 204)
  invalid/                 requests that fail validation (expect 200 with nbr 2)
  malformed/               bodies that are not JSON (expect 400)
```

The fixtures and expectations match the Node.js bidder from
https://rtblint.org/learn/build-a-bidder-node/. The workflow assumes
`server.mjs`, `package.json`, and `package-lock.json` at the repository root.
Run `npm install` once and commit the lock file, because the workflow uses
`npm ci`.

## Run locally

Install the CLI (`cargo install rtblint --version 0.14.7`, or download a
release from https://github.com/aleksUIX/rtblint/releases/tag/v0.14.7),
start the bidder, then:

```sh
bash scripts/test-bidder.sh fixtures
```

`BIDDER_URL` (default `http://localhost:8080/bid`), `SPEC` (default
`2.6-202606`), and `OUT` (default `out`) can be set in the environment.
Responses are written to `OUT` so a failing run can be inspected.

## Exit codes

The script exits 0 when every fixture passes, 1 when any fixture fails, and 2
when `rtblint` itself cannot run (a missing file or an unknown spec version).
