MockHttpClient class

Mock HTTP client implementation for testing purposes.

This client allows you to define mock responses for specific URLs, making it easy to test your bot logic without making real HTTP requests.

Implemented types

Constructors

MockHttpClient.new(Map<String, Map<String, dynamic>> _responses)
Creates a new MockHttpClient with the given mock responses.

Properties

hashCode int
The hash code for this object.
no setterinherited
lastRequest MockRequest?
Gets the last request made to this client.
no setter
requestHistory List<MockRequest>
Gets the request history for testing verification.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addResponse(String urlPattern, Map<String, dynamic> response) → void
Adds a mock response for the specified URL pattern.
clearHistory() → void
Clears the request history.
close() Future<void>
Closes the HTTP client and releases any resources.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
post(String url, [Payload? payload]) Future<Map<String, dynamic>>
Makes a POST request to the specified url with the given payload.
override
toString() String
A string representation of this object.
inherited

Operators

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