Skip to content

Allow injection of custom HttpMessageHandler #516

@shuebner

Description

@shuebner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy