Expand description
Test doubles for nitr test: canned outbound responses and
environment overrides, installed by a test as data and read by the
standard library at the seams that honour them.
A test file and the server’s pooled states are separate Lua universes,
so a double cannot be a Lua function patched into nitr.*: it would
change the test’s state and nothing a handler sees. Instead the runner
puts one Doubles into the app data of every state it builds — the
pooled ones through ServerBuilder::setup, which also runs on a
poison rebuild and a reload, and its own test state directly — and the
setters live under nitr.test, which only the runner registers.
Absent app data means no double: that is the production path, and it
costs each seam one app-data lookup. The types here are plain data, so
the module compiles in every feature set even though the fetch seam
exists only with fetch.
Structs§
- Canned
- The canned response a matched rule produced.
- Doubles
- Every double a test can install, shared by the test state and every pooled state of the server under test.
- Fetch
Call - One outbound call made while the doubles were installed, whether a rule answered it or not.
- Fetch
Mock - Canned responses, the recorded calls, and the strict flag.
- Fetch
Rule - One canned answer for
nitr.fetch. - Mocked
Failure - The failure a
t.fetch.mock { error = ... }rule raises.
Enums§
- Fetch
Answer - What the double says about one outbound request.
- UrlMatch
- How a rule matches a request URL.
Constants§
- MAX_
RECORDED_ CALLS - How many outbound calls a test records before the oldest are dropped: a chatty handler must not grow the record without bound.
Functions§
- session_
cookie_ value - The value
session:savewould write fordata: the JSON payload (with the expiry whenmax_ageis set) signed forname— so a test can put a session into a client’s jar without a login round trip.