FaultPlan class final

A queue of fault rules, matched in order (Design note 4).

REST rules wait for the next request of their operation and apply times times; gateway faults act at once (or after after). Nothing is random, so a test sees the same faults on every run.

Example:

server.faults
  ..onRequest('createMessage', status: 503, code: 'unavailable',
      retryAfter: const Duration(milliseconds: 20))
  ..dropResponseAfterCommit('createMessage');
server.faults.closeGateway(4000);

Constructors

FaultPlan(GatewayFaultTarget _gateway)
Creates the plan acting on the gateway of the fake server.

Properties

hashCode → int
The hash code for this object.
no setterinherited
pending → List<RequestFault>
The REST rules that have not been used up, in order.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancelTimers() → void
Cancels the gateway faults that wait for their delay.
closeGateway(int code, {String? reason, Duration? after}) → void
Closes every gateway connection with code and reason, now or after a delay.
delay(Duration duration, {String? operationId, int times = 1}) → void
Holds the responses of the next times requests of operationId (of any operation when null) for duration after they were handled.
dropResponseAfterCommit(String operationId, {int times = 1}) → void
Stores the next times writes of operationId and closes their connection before the response (a lost response after the commit, 04 16.2).
duplicateNextDispatch() → void
Delivers the next dispatch twice (at-least-once delivery, 04 9).
holdDispatches() → void
Holds every dispatch until releaseDispatches.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onRequest(String operationId, {required int status, required String code, String? reason, Duration? retryAfter, int times = 1}) → void
Answers the next times requests of operationId with status and a problem with code and reason (409, 410, 412, 429, 5xx), with Retry-After when retryAfter is set.
releaseDispatches() → void
Sends the held dispatch frames and delivers again.
resyncRequired(String reason) → void
Answers the next session start with a cursor with resync_required and reason (epoch_changed, retention, too_far_behind, cursor_ahead, 04 7.3).
revoke({String? deviceId}) → void
Closes every connection of deviceId (every device when null) with 4012 and marks their sessions revoked (04 8.5).
take(String operationId) → RequestFault?
The fault for the next request of operationId, used up by one; null when no rule matches. The fake server calls this once per request.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited