Skip to content

Specifications

This page shows the executable specifications (E2E tests) for interposition. These specifications serve as living documentation - they are always in sync with the actual behavior.

Record specification

Broker raises error for MISS in replay mode

  • Create empty cassette
  • Broker in "replay" mode receives request for "test-proto" "fetch" "resource-123"
  • Broker should raise InteractionNotFoundError

Broker requires live responder in auto mode

  • Create empty cassette
  • Broker in "auto" mode receives request for "test-proto" "fetch" "resource-123"
  • Broker should raise LiveResponderRequiredError

Broker requires live responder in record mode

  • Create empty cassette
  • Broker in "record" mode receives request for "test-proto" "fetch" "resource-123"
  • Broker should raise LiveResponderRequiredError

Broker forwards MISS to live upstream in auto mode

  • Create empty cassette
  • Configure mock live responder returning "live-response-data"
  • Broker in "auto" mode receives request for "test-proto" "fetch" "resource-123"
  • Response stream should contain "live-response-data"
  • Cassette should contain one recorded interaction

Broker forwards MISS to live upstream in record mode

  • Create empty cassette
  • Configure mock live responder returning "live-response-data"
  • Broker in "record" mode receives request for "test-proto" "fetch" "resource-123"
  • Response stream should contain "live-response-data"
  • Cassette should contain one recorded interaction

Broker does not forward HIT in auto mode

  • Create cassette with recorded interaction for "test-proto" "fetch" "resource-123"
  • Configure tracking live responder returning "live-response-data"
  • Broker in "auto" mode receives request for "test-proto" "fetch" "resource-123"
  • Response stream should contain recorded chunks in order
  • Live responder should not be called

Broker always forwards to live in record mode even on HIT

  • Create cassette with recorded interaction for "test-proto" "fetch" "resource-123"
  • Configure tracking live responder returning "fresh-live-data"
  • Broker in "record" mode receives request for "test-proto" "fetch" "resource-123"
  • Live responder should be called
  • Response stream should contain "fresh-live-data"

Recorded cassette can be serialized and replayed

  • Create empty cassette
  • Configure mock live responder returning "recorded-data"
  • Broker in "auto" mode receives request for "test-proto" "fetch" "resource-123"
  • Serialize and deserialize cassette
  • Broker in "replay" mode receives request for "test-proto" "fetch" "resource-123"
  • Response stream should contain "recorded-data"

Replay specification

Broker replays matching interaction

  • Create cassette with recorded interaction for "test-proto" "fetch" "resource-123"
  • Broker receives identical request for "test-proto" "fetch" "resource-123"
  • Response stream should contain recorded chunks in order
  • Response stream should complete without errors

Broker raises error for unmatched request

  • Create cassette with recorded interaction for "test-proto" "fetch" "resource-123"
  • Broker receives different request for "test-proto" "store" "resource-456"
  • Broker should raise InteractionNotFoundError

Broker returns first matching interaction

  • Create cassette with two identical interactions for "test-proto" "fetch" "resource-123"
  • Broker receives request for "test-proto" "fetch" "resource-123"
  • Response stream should contain chunks from FIRST recorded interaction

Broker treats header order as significant

  • Create cassette with recorded interaction headers "X-First:1,X-Second:2"
  • Broker receives request with headers "X-Second:2,X-First:1"
  • Broker should raise InteractionNotFoundError