Skip to content

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

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 63 lines in your changes missing coverage. Please review.

Project coverage is 87.37%. Comparing base (9bf46c1) to head (3da70af).
Report is 248 commits behind head on master.

Files with missing lines Patch % Lines
Client/InfluxDBClient.cs 0.00% 63 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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