Skip to content

[Janitor] test(cmd): strengthen root command tests with table-driven approach#44

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
janitor/strengthen-root-tests-dad11112e2cedf5a
Draft

[Janitor] test(cmd): strengthen root command tests with table-driven approach#44
github-actions[bot] wants to merge 1 commit into
mainfrom
janitor/strengthen-root-tests-dad11112e2cedf5a

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Refactors internal/cmd/root_test.go to use a single table-driven test covering all root command behaviors, including a previously untested code path.

Changes:

  • Consolidates TestRootExecutes and TestVersionCommand into one table-driven TestRootCommand
  • Adds a test case for the --version flag (cobra built-in, was not covered)
  • Adds a test case for the unknown command error path
  • Strengthens the --help assertion to verify "myapp" appears in output (was only checking non-empty)
  • Captures both stdout and stderr in one buffer for reliable output checking

No behavior changes — tests only.


🤖 Janitor bot: automated test quality improvement (task: Strengthen existing tests)

Generated by Janitor · ● 5.4M ·

- Replace two separate test functions with a single table-driven TestRootCommand
- Add test for --version flag (cobra built-in, previously untested)
- Add test for unknown command error path
- Strengthen help assertion to verify 'myapp' appears in output
- Use SetErr to capture error output in the same buffer

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants