-
Notifications
You must be signed in to change notification settings - Fork 96
Description
Proposal:
Add the possibility to provide a custom HttpMessageHandler
to InfluxDBClient
e. g. for testing.
Current behavior:
ApiClient
does have a settable RestClient
property via which it is possible to inject a custom HttpMessageHandler
.
However, it is not possible to inject that ApiClient
into InfluxDBClient
because the ApiClient
construction is hard-coded into the InfluxDBClient
ctor.
Atm I use reflection to overwrite the _apiClient
field in InfluxDBClient
after construction, which is a brittle hack.
Desired behavior:
Provide some way (ctor, options, anything) of reliably either setting the HttpMessageHandler
or, less desirable IMHO the RestClient
under the hood.
Alternatives considered:
Overwrite InfluxDBClient._apiClient
via reflection.
Use case:
I am writing E2E unit tests for an application query flow from application to InfluxDB and back.
To include as much code as possible and be as realistic as possible, I did not mock InfluxDBClient, but used a traffic-replay of the CSV from a real InfluxDB for a real query with real (non-confidential) data.
A custom HttpMessageHandler
returns that canned CSV.
This enables testing without guessing how the CSV is deserialized into FluxTable
etc. and thus makes it more realistc and robust.