Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

test: improve test coverage across multiple packages #571

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

colek42
Copy link
Member

@colek42 colek42 commented Mar 21, 2025

Summary

This PR significantly improves test coverage across the codebase:

  • Added comprehensive tests for options package (0% → 76.9%)
  • Added tests for internal/archivista package (0% → 100%)
  • Enhanced cmd package test coverage (33.3% → 75.8%)
  • Overall project coverage improved from 24.5% to 66.1% (+41.6%)

Test Approach

  • Black-box testing through public interfaces
  • Mocking of external dependencies (filesystem, signers, verifiers)
  • Table-driven tests for multiple scenarios
  • Error path testing
  • Unit tests for previously untested functions

Changes

  • Added 15 new test files across multiple packages
  • Modified root.go to allow for testing the Execute function
  • Implemented mock patterns for testing code with external dependencies
  • Created helper functions for common test patterns
  • Fixed linting errors and correctly handled all error return values

Copy link

netlify bot commented Mar 21, 2025

Deploy Preview for witness-project ready!

Name Link
🔨 Latest commit 96b3ba8
🔍 Latest deploy log https://app.netlify.com/sites/witness-project/deploys/67dddd8e7623690008a03339
😎 Deploy Preview https://deploy-preview-571--witness-project.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

- Added comprehensive tests for options package (0% → 76.9%)
- Added tests for internal/archivista package (0% → 100%)
- Enhanced cmd package test coverage (33.3% → 75.8%)
- Modified root.go to allow for testing the Execute function
- Added tests for previously untested functions
- Implemented mock patterns for external dependencies
- Used table-driven tests for comprehensive test cases

Overall project coverage improved from 24.5% to 66.1% (+41.6%)

Signed-off-by: Cole Kennedy <[email protected]>
@colek42 colek42 force-pushed the improve-test-coverage branch from a66a8c5 to b24ef15 Compare March 21, 2025 21:35
Cole Kennedy added 3 commits March 21, 2025 16:38
Fixed errcheck linting errors by properly checking return values for:
- io.Copy calls in test files
- flags.Set calls
- RunE calls

These fixes ensure all test code properly handles potential errors.

Signed-off-by: Cole Kennedy <[email protected]>
Fix TestVerifyCmdDeprecatedFlag to ignore error return value from RunE
since the command is expected to fail with a specific error message
that isn't the focus of the test.

Signed-off-by: Cole Kennedy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant