InfluxDBRequestHandlerMock
In-memory stand-in for HttpPromise.request used to test InfluxDB writes without making real HTTP calls. Inject its InfluxDBRequestHandlerMock.Handler wherever an InfluxDBRequestHandler is expected -- into InfluxDBClient.new, via InfluxDBService.SetRequestHandler, or use InfluxDBClient.newMock, which wires one up for you.
Every request handed to the mock is recorded for inspection. By default each request resolves with a 204 success response; call InfluxDBRequestHandlerMock.SetResponder to control the response (for example to simulate a failure).
local requestMock = InfluxDBRequestHandlerMock.new()
local client = InfluxDBClient.new(config, requestMock.Handler)
-- ...write some points...
print(#requestMock:GetRequests())
Types
Responder
A responder controls how the mock answers a request, so a test can resolve or reject however it needs.
Functions
isInfluxDBRequestHandlerMock
InfluxDBRequestHandlerMock.isInfluxDBRequestHandlerMock(value: any) → booleanReturns whether the given value is an InfluxDBRequestHandlerMock.
new
Constructs a new InfluxDBRequestHandlerMock.
SetResponder
Sets a responder invoked for each subsequent request, letting a test resolve or reject however it needs. Pass nil to restore the default 204 success response.
GetRequests
InfluxDBRequestHandlerMock.GetRequests(self: InfluxDBRequestHandlerMock) → {HttpPromise.HTTPRequest}Returns every request handed to the mock, in order.
GetLastRequest
InfluxDBRequestHandlerMock.GetLastRequest(self: InfluxDBRequestHandlerMock) → HttpPromise.HTTPRequest?Returns the most recent request handed to the mock, or nil if there have been none.