Improve tests and coverage: add tests and small fixes to reach full line coverage#151
Merged
fityannugroho merged 6 commits intomainfrom Sep 2, 2025
Merged
Improve tests and coverage: add tests and small fixes to reach full line coverage#151fityannugroho merged 6 commits intomainfrom
fityannugroho merged 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves test coverage and code reliability by adding comprehensive tests for edge cases and making small behavior-preserving changes to achieve full line coverage.
- Adds extensive test coverage for duplicate filename handling and error scenarios
- Refactors duplicate filename logic for better testability while preserving behavior
- Improves coverage configuration to exclude test artifacts from metrics
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Excludes coverage and test directories from coverage metrics |
| test/index.spec.ts | Adds comprehensive tests for duplicate filename scenarios and edge cases |
| test/helpers/paths.ts | Fixes Windows path separators and adds new test path constants |
| test/downloader.spec.ts | Adds error handling tests for directory permissions and stream failures |
| test/cli.spec.ts | Refactors CLI tests to use direct function calls instead of subprocess execution |
| src/index.ts | Refactors duplicate filename handling logic for better testability |
| src/cli.ts | Extracts runner function to enable direct testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…platform compatibility
Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request raises test coverage by adding targeted tests for edge cases and making small, behavior-preserving clarifications to the source code so tests are deterministic and reliable.
What changed
Tests
test/index.spec.tsto add duplicate-filename scenarios and ensure filenames and paths are cleaned up after test runs.test/downloader.spec.tsto add error-path tests that exercise response validation and write/cleanup logic.Source (small, behavior-preserving)
src/index.ts: clarified and simplified the duplicate-filename handling so filename suffixing is deterministic and testable. No changes to public API or behavior from a caller's perspective.vitest.config.ts: improved coverage exclusion configuration to avoid counting test/coverage artifacts in the report.Why
The main goal was to ensure the library has robust tests for edge cases (duplicate filenames, stream errors and cleanup) and to improve the reliability of coverage reporting so we can trust the metrics.
Verification performed locally
src/files: 100% statements, 100% lines, 100% functions. Branch coverage improved to ~98-99% (minor instrumentation gaps for some inline branches).Notes for reviewers
src/index.tsis intended to be behavior-preserving (duplicate filename suffixing remains the same logically, but the code is clearer).main, let me know and I will update it.Next steps
If you want, I can squash commits or rebase before merging.