The task
src/cli/config-command.ts has no test coverage. It is 44 lines and implements the cve-lite config subcommands: showing the current configuration, setting a value, and unsetting one.
This one is a step up from the first-timers-only issues because the function writes to console.log, so the tests need to capture that rather than just assert a return value.
What to cover
show with no configuration set prints "No configuration set." and the config file path
show with a caCert configured prints the key and its value
set with a valid certificate path stores it
set with an invalid path surfaces the validation error from validateCaCertFile
unset removes a previously stored value
Getting started
tests/cli/config.test.ts already tests the underlying config.ts module and shows how to redirect HOME to a temporary directory so the real user config is never touched. Follow that pattern; a test that writes to the developer's actual config file would be a bug in the test.
For the console output, use jest.spyOn(console, "log") and restore it afterwards.
Steps
- Comment here to claim it.
- Branch, for example
test/config-command-coverage.
npm install, then npm test to confirm a clean start.
- Add
tests/cli/config-command.test.ts.
npm test must pass, and no test may leave files behind outside its temp directory.
- Open a PR with
Closes #NNN.
Please do not change the behaviour of config-command.ts itself. If you find a genuine bug while writing the tests, mention it here and we will treat it separately.
The task
src/cli/config-command.tshas no test coverage. It is 44 lines and implements thecve-lite configsubcommands: showing the current configuration, setting a value, and unsetting one.This one is a step up from the
first-timers-onlyissues because the function writes toconsole.log, so the tests need to capture that rather than just assert a return value.What to cover
showwith no configuration set prints "No configuration set." and the config file pathshowwith acaCertconfigured prints the key and its valuesetwith a valid certificate path stores itsetwith an invalid path surfaces the validation error fromvalidateCaCertFileunsetremoves a previously stored valueGetting started
tests/cli/config.test.tsalready tests the underlyingconfig.tsmodule and shows how to redirectHOMEto a temporary directory so the real user config is never touched. Follow that pattern; a test that writes to the developer's actual config file would be a bug in the test.For the console output, use
jest.spyOn(console, "log")and restore it afterwards.Steps
test/config-command-coverage.npm install, thennpm testto confirm a clean start.tests/cli/config-command.test.ts.npm testmust pass, and no test may leave files behind outside its temp directory.Closes #NNN.Please do not change the behaviour of
config-command.tsitself. If you find a genuine bug while writing the tests, mention it here and we will treat it separately.