test(cmd): add unit tests and flag validation for the test command#365
Open
divyansh-v15-06 wants to merge 1 commit into
Open
test(cmd): add unit tests and flag validation for the test command#365divyansh-v15-06 wants to merge 1 commit into
divyansh-v15-06 wants to merge 1 commit into
Conversation
|
Welcome to the Microcks community! 💖 Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly. Hope you have a great time there! |
- Extracted flag parsing logic in test.go to a separate parseWaitFor function - Created test_test.go with comprehensive table-driven tests for time parsing - Verified TestCommand initialization and default flag values Signed-off-by: rika <divyanshanshu90@gmail.com>
fcea4c6 to
127af68
Compare
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.
What does this PR do?
This PR introduces critical test coverage for the
testcommand (cmd/test.go), which previously lacked a corresponding unit test file.Specifically, this PR:
--waitForstring-parsing logic from the mainRunblock into an isolated, package-privateparseWaitForfunction.cmd/test_test.gowith standard Go table-driven tests. These thoroughly validate theparseWaitForlogic, ensuring different units (milli,sec,min) are parsed correctly and mathematically sound.NewTestCommandinitializes correctly with all expected flags and default values intact.Why is this important?
The
testcommand is a core component of themicrocks-cli. By extracting and testing the time-parsing logic, this PR prevents future regressions in how test timeouts are calculated, and ensures that invalid user input is handled gracefully.How to test this?
cmdpackage:go test -v ./cmd/test_test.go