Skip to content

Improve tests and coverage: add tests and small fixes to reach full line coverage#151

Merged
fityannugroho merged 6 commits intomainfrom
test
Sep 2, 2025
Merged

Improve tests and coverage: add tests and small fixes to reach full line coverage#151
fityannugroho merged 6 commits intomainfrom
test

Conversation

@fityannugroho
Copy link
Owner

@fityannugroho fityannugroho commented Sep 2, 2025

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

    • Updated test/index.spec.ts to add duplicate-filename scenarios and ensure filenames and paths are cleaned up after test runs.
    • Updated test/downloader.spec.ts to 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

  • Ran the full test suite: 113 tests passed.
  • Coverage (v8 provider):
    • src/ files: 100% statements, 100% lines, 100% functions. Branch coverage improved to ~98-99% (minor instrumentation gaps for some inline branches).

Notes for reviewers

  • No breaking API changes. The change in src/index.ts is intended to be behavior-preserving (duplicate filename suffixing remains the same logically, but the code is clearer).
  • Please review the added tests for correctness and style.
  • If you'd like the PR opened against a different base branch instead of main, let me know and I will update it.

Next steps

  • Merge when ready. I can also add reviewers or labels if you want.

If you want, I can squash commits or rebase before merging.

Copilot AI review requested due to automatic review settings September 2, 2025 09:08

This comment was marked as outdated.

Copy link

Copilot AI left a comment

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 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.

@fityannugroho fityannugroho merged commit 914fe2c into main Sep 2, 2025
5 checks passed
@fityannugroho fityannugroho deleted the test branch September 2, 2025 10:11
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