Skip to content

test(cmd): add unit tests and flag validation for the test command#365

Open
divyansh-v15-06 wants to merge 1 commit into
microcks:masterfrom
divyansh-v15-06:chore/add-test-cmd-tests
Open

test(cmd): add unit tests and flag validation for the test command#365
divyansh-v15-06 wants to merge 1 commit into
microcks:masterfrom
divyansh-v15-06:chore/add-test-cmd-tests

Conversation

@divyansh-v15-06
Copy link
Copy Markdown

What does this PR do?

This PR introduces critical test coverage for the test command (cmd/test.go), which previously lacked a corresponding unit test file.

Specifically, this PR:

  1. Refactors Flag Parsing: Extracts the inline --waitFor string-parsing logic from the main Run block into an isolated, package-private parseWaitFor function.
  2. Adds Comprehensive Tests: Introduces cmd/test_test.go with standard Go table-driven tests. These thoroughly validate the parseWaitFor logic, ensuring different units (milli, sec, min) are parsed correctly and mathematically sound.
  3. Verifies Command Wiring: Adds a test block to ensure NewTestCommand initializes correctly with all expected flags and default values intact.

Why is this important?

The test command is a core component of the microcks-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?

  1. Check out this branch.
  2. Run the tests in the cmd package:
    go test -v ./cmd/test_test.go

@github-actions
Copy link
Copy Markdown

👋 @divyansh-v15-06

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>
@divyansh-v15-06 divyansh-v15-06 force-pushed the chore/add-test-cmd-tests branch from fcea4c6 to 127af68 Compare May 11, 2026 14:50
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