stub method

void stub(
  1. HttpMethod method,
  2. String endpoint,
  3. Either<Failure, Response> result
)

Queues result for the next call to method endpoint.

Stub the same endpoint more than once to script a sequence — each call consumes one entry, and the last one repeats once the queue runs dry. That makes "fails, then succeeds on retry" straightforward to set up.

Implementation

void stub(
  HttpMethod method,
  String endpoint,
  Either<Failure, Response> result,
) {
  _stubs.putIfAbsent(_key(method, endpoint), () => []).add(result);
}