Skip to content

test: Improve test coverage for ServiceCollectionExtensions and providers - #23

Merged
steingran merged 1 commit into
mainfrom
test-coverage
Nov 12, 2025
Merged

test: Improve test coverage for ServiceCollectionExtensions and providers#23
steingran merged 1 commit into
mainfrom
test-coverage

Conversation

@steingran

@steingran steingran commented Nov 12, 2025

Copy link
Copy Markdown
Owner

Description

Add comprehensive unit and integration tests to improve code coverage across multiple providers, increasing overall test count from 283 to 328 tests.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧪 Test improvements
  • ⚡ Performance improvement
  • ♻️ Code refactoring
  • 🔧 Maintenance/chore

Related Issue

Changes Made

  • Add ServiceCollectionExtensions tests for InMemory, FileSystem, and ZooKeeper providers (100% coverage achieved for all extension methods)
  • Add 10 FileSystem provider integration tests covering lease expiration, health checks, metadata updates, and auto-directory creation
  • Add 9 ZooKeeper provider integration tests covering edge cases including node reuse, disposal scenarios, metadata updates, and multiple election groups
  • Fix ambiguous JsonSerializer.Deserialize call in RedisLeaderElectionProvider

Coverage improvements:

  • InMemory ServiceCollectionExtensions: 0% → 100%
  • FileSystem ServiceCollectionExtensions: 0% → 100%
  • FileSystem provider: 52.8% → 76%
  • ZooKeeper ServiceCollectionExtensions: 25% → 100%
  • ZooKeeper provider: 69.7% → 71.1%

All 328 tests passing with proper infrastructure running.

Testing

  • Unit tests pass locally
  • Integration tests pass locally
  • Added new tests for new functionality
  • All existing tests still pass

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Labels

Additional Notes

Copilot AI review requested due to automatic review settings November 12, 2025 20:44
@steingran steingran added the test Test improvements or additions label Nov 12, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR significantly enhances test coverage for the MultiLock library by adding comprehensive unit tests for ServiceCollectionExtensions across multiple providers (InMemory, FileSystem, ZooKeeper) and integration tests for FileSystem and ZooKeeper providers. The changes also include a fix for an ambiguous method call in the Redis provider.

Key Changes:

  • Added complete test coverage (100%) for ServiceCollectionExtensions of InMemory, FileSystem, and ZooKeeper providers
  • Added 10 new FileSystem integration tests covering core scenarios and edge cases
  • Added 9 new ZooKeeper integration tests for advanced scenarios including disposal, metadata updates, and multi-group elections

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/MultiLock.Tests/ZooKeeperServiceCollectionExtensionsTests.cs New test file providing comprehensive unit tests for all ZooKeeper DI extension method overloads
tests/MultiLock.Tests/InMemoryServiceCollectionExtensionsTests.cs New test file with unit tests covering InMemory provider DI registration scenarios
tests/MultiLock.Tests/FileSystemServiceCollectionExtensionsTests.cs New test file testing FileSystem provider DI registration with various configuration options
tests/MultiLock.IntegrationTests/ZooKeeperIntegrationTests.cs Updated existing tests to use await using for proper async disposal and added 9 new integration tests for edge cases
tests/MultiLock.IntegrationTests/FileSystemIntegrationTests.cs New integration test file with 10 tests covering FileSystem provider behavior including auto-directory creation
src/Providers/MultiLock.Redis/RedisLeaderElectionProvider.cs Fixed ambiguous JsonSerializer.Deserialize call by adding explicit cast to string

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/MultiLock.IntegrationTests/FileSystemIntegrationTests.cs
Comment thread tests/MultiLock.IntegrationTests/FileSystemIntegrationTests.cs Outdated
@codecov

codecov Bot commented Nov 12, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.24%. Comparing base (1cf0f76) to head (ed69f6e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   70.98%   74.24%   +3.25%     
==========================================
  Files          36       36              
  Lines        2244     2244              
  Branches      305      305              
==========================================
+ Hits         1593     1666      +73     
+ Misses        533      463      -70     
+ Partials      118      115       -3     
Files with missing lines Coverage Δ
...ers/MultiLock.Redis/RedisLeaderElectionProvider.cs 79.36% <100.00%> (ø)

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

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

…ders

Add comprehensive unit and integration tests to improve code coverage across multiple providers, increasing overall test count from 283 to 328 tests.

Changes:
- Add ServiceCollectionExtensions tests for InMemory, FileSystem, and ZooKeeper  providers (100% coverage achieved for all extension methods)
- Add 10 FileSystem provider integration tests covering lease expiration, health checks, metadata updates, and auto-directory creation
- Add 9 ZooKeeper provider integration tests covering edge cases including node reuse, disposal scenarios, metadata updates, and multiple election groups
- Fix ambiguous JsonSerializer.Deserialize call in RedisLeaderElectionProvider

Coverage improvements:
- InMemory ServiceCollectionExtensions: 0% → 100%
- FileSystem ServiceCollectionExtensions: 0% → 100%
- FileSystem provider: 52.8% → 76%
- ZooKeeper ServiceCollectionExtensions: 25% → 100%
- ZooKeeper provider: 69.7% → 71.1%

All 328 tests passing with proper infrastructure running.
@steingran
steingran merged commit d8d5b6b into main Nov 12, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Test improvements or additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants