Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds missing tests to enhance functionality and maintainability by introducing comprehensive unit tests for various git-secret commands, updating the test script in package.json, and including a minor improvement with a TODO in the logging utility.
- Added detailed unit tests for commands such as add, cat, tell, reveal, and more.
- Updated package.json to include a "test" script using vitest.
- Added a TODO comment in logger.ts to consider replacing console.log with a more robust logging solution.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| vite.config.ts | Adds coverage exclusion configuration for tests |
| test/commands/*.test.ts | Introduces comprehensive unit tests for most git-secret commands |
| src/utils/logger.ts | Updates logger with a TODO comment to switch to a better logging lib |
| package.json | Updates scripts to add the "test" command |
| @@ -1,3 +1,5 @@ | |||
| // TODO: Change this to use winston or something similar. | |||
There was a problem hiding this comment.
Since this file is used in production code, consider replacing the current console.log-based logger with a robust solution such as Winston as indicated by the TODO comment.
| const mockNormalizedPath = 'file.txt'; | ||
| const mockAbsolutePath = '/path/to/git/repo/file.txt'; | ||
|
|
||
| beforeEach(() => { |
There was a problem hiding this comment.
[nitpick] The test files share similar setup logic; consider extracting common mock setup functions into a shared helper module to reduce duplication and improve maintainability.
This pull request introduces several changes to enhance the functionality, testing, and maintainability of the project. The most significant updates include the addition of test scripts, comprehensive unit tests for the
addandcatcommands, and a minor improvement to the logging utility.Testing Enhancements:
testscript topackage.jsonto enable running tests usingvitest.addcommand intest/commands/add.test.ts, covering scenarios such as adding single and multiple files, handling verbose mode, and aborting on errors like missing files or files already tracked by Git.catcommand intest/commands/cat.test.ts, covering scenarios such as decrypting files, handling multiple files, using environment variables for decryption, and error propagation.Code Improvements:
TODOcomment insrc/utils/logger.tssuggesting the replacement of the current logging implementation with a more robust library like Winston.