DpExchange.Gemini.Fake (DpExchangeGemini v0.1.1)

Copy Markdown View Source

An in-process Gemini, for a consumer's tier-1 tests and for the conformance suite's active-endpoint assertion.

It is not a mock. Nothing is stubbed, no expectation is recorded, and no call is verified. It is a real implementation of DpExchange.Core.Venue that answers from memory instead of from the network, and it runs the same conformance suite as the real adapter.

Two rules

Less capable is allowed. Differently capable is not. Where this cannot answer, it returns an error. It never returns an empty success for something unsupported — a plausible wrong answer is worse than a failure, because only one of the two gets noticed.

It never rewrites a value the caller supplied, and it never stamps the current clock. @at below is fixed, because a fake that stamps utc_now/0 cannot be used to test anything about freshness and is itself the substitution this family refuses.

It models Gemini's refusals, and its two shapes of refusal differ

A fake where everything works proves half the contract. This one refuses:

  • a symbol it does not carry, with {:refused, :not_listed} — permanent, and distinct from a transient error;
  • a timeframe Gemini does not serve, including 2h, 4h and 12h, which the shared vocabulary models and this venue does not;
  • a range reaching before the venue's fixed window, with {:range_unavailable, …} rather than a short answer — because the real endpoint ignores bounds entirely and a truncated result reads as a complete one.

That last one is this venue's distinctive failure mode, and a consumer that has not handled it will find out here rather than in production.