jevcrates.git / jev-http / tests / README.md

Chapter 20¾: jev-http/tests — the whole client, over real TLS

One file, mock.rs: an integration test. Cargo builds each file in a crate's tests/ folder as a separate program that can use only the crate's public API, the way an outside caller would. (The nearest JavaScript equivalent is an end-to-end test that imports the package by name rather than reaching into its source.)

Every test starts jev_mock::MockJev on loopback, points a Jev at it with Endpoint::parse(&mock.endpoint()).trusting(mock.ca_file()), and gives it a ledger in a fresh temp directory. Nothing reaches the real API and nothing touches the real ledger.

flowchart LR
  T["test"] --> J["Jev::ask"]
  J --> L[("sandbox ledger")]
  J -->|"HTTP/2 over TLS, throwaway CA"| M["MockJev on 127.0.0.1"]
  M -->|"Reply from the test's closure"| J
TestShows
answers_over_one_kept_connection_and_books_the_costThree asks, three requests, one TLS connection; every hold settled.
the_ledger_refuses_before_anything_is_sentWith a bucket of one, the second ask is Failure::Throttled and the mock sees one request.
out_of_credit_stops_every_later_askA 402 is OutOfCredit after one attempt, the next ask is Failure::Budget without a request, and the refused hold was released.
a_plain_http_endpoint_is_refusedEndpoint::parse refuses http://.

Try it

cargo test -p jev-http --test mock

For the people who maintain it

In this folder

FileWhat
mock.rsThe four tests above, and the client and one_noul helpers.
CLAUDE.mdInvariants for agents.

← Previous: Chapter 20½: inside jev-http/src · Up: jev-http · Next: Chapter 21: jev-mock →