Skip to content

feat: add interfaces to client's APIs #327

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Jun 13, 2022
Merged

feat: add interfaces to client's APIs #327

merged 3 commits into from
Jun 13, 2022

Conversation

bednar
Copy link
Contributor

@bednar bednar commented Jun 10, 2022

Closes #325

Proposed Changes

Added interfaces to APIs to be able to use moq library:

var mockClient = new Mock<IInfluxDBClient>();
var mockQueryApi = new Mock<IQueryApiSync>();

mockClient
    .Setup(library => library.GetQueryApiSync(null))
    .Returns(mockQueryApi.Object);

var mockTables = new List<FluxTable> { new FluxTable() };
mockQueryApi
    .Setup(api => api.QuerySync("from(...", "my-org", CancellationToken.None))
    .Returns(mockTables);

var tables = mockClient.Object.GetQueryApiSync().QuerySync("from(...", "my-org");
Assert.AreEqual(mockTables, tables);

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • dotnet test completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@bednar bednar added the enhancement New feature or request label Jun 10, 2022
@bednar bednar requested a review from rhajek June 10, 2022 09:45
@bednar bednar marked this pull request as ready for review June 10, 2022 09:45
@bednar bednar changed the title feat: add interfaces to our APIs feat: add interfaces to client's APIs Jun 10, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2022

Codecov Report

Merging #327 (3da70af) into master (9bf46c1) will decrease coverage by 0.83%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #327      +/-   ##
==========================================
- Coverage   88.21%   87.37%   -0.84%     
==========================================
  Files          76       76              
  Lines        6565     6628      +63     
==========================================
  Hits         5791     5791              
- Misses        774      837      +63     
Impacted Files Coverage Δ
Client.Legacy/FluxClient.cs 99.13% <ø> (ø)
Client/AuthorizationsApi.cs 87.50% <ø> (ø)
Client/BucketsApi.cs 74.12% <ø> (ø)
Client/ChecksApi.cs 100.00% <ø> (ø)
Client/DeleteApi.cs 100.00% <ø> (ø)
Client/InfluxDBClient.cs 76.01% <0.00%> (-20.56%) ⬇️
Client/InvokableScriptsApi.cs 9.09% <ø> (ø)
Client/LabelsApi.cs 96.92% <ø> (ø)
Client/NotificationEndpointsApi.cs 93.25% <ø> (ø)
Client/NotificationRulesApi.cs 91.80% <ø> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9bf46c1...3da70af. Read the comment docs.

@bednar bednar merged commit a9182ab into master Jun 13, 2022
@bednar bednar deleted the ability_to_mocking branch June 13, 2022 05:36
@bednar bednar added this to the 4.3.0 milestone Jun 13, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add public parameterless constructor to InfluxDbClient to allow mocking for unit test
3 participants