Expand description
Fake HAFAS ReST server on loopback that serves trimmed RMV responses, for tests.
The answers come from fixtures/, one set per dialect version: 2.39
below /hapi/ and 2.52 below /hapi/latest/, as on the RMV server.
Injections change them, to produce cancellations, delays and errors on
demand. Every request is recorded, so tests can check what was sent, and
that nothing was sent.
The sim accepts only ACCESS_ID. It answers a request without a key
and one with another key with the errors of the RMV server, but it never
repeats the key it was sent.
use hafas_sim::{Failure, Injection, Sim};
let sim = Sim::start().await;
sim.inject(Injection::Fail(Failure::status(503).times(1)));
// point the client under test at sim.base_url() or sim.latest_url()
assert_eq!(sim.requests().len(), 0);Structs§
- Failure
- An error answer, for
Injection::Fail. - Recorded
- A request the sim received. A key other than
ACCESS_IDis recorded asREDACTED. - Sim
- A running sim. It stops when dropped.
Enums§
- Endpoint
- The services the sim serves.
- Injection
- A change to the answers of the sim. Injections stay until
Sim::clear. - Version
- A dialect version of the API, with its own fixtures.
Constants§
- ACCESS_
ID - The access key the sim accepts.
- CANCELLED_
JOURNEY - The journey of
journeyDetail-cancelled.json(2.39): the tram 17 at 09:10, cancelled.journeyDetailanswers with that fixture for it. - DEPARTURE_
JOURNEY - The first departure of
departureBoard.json(2.39): the S2 at 08:40. - REDACTED
- What a recorded request holds instead of a key that is not
ACCESS_ID.
Functions§
- fixture
- The fixture
nameofversion, liketrip.jsonorerrors/auth.xml.