4af74c3da8
The mro-based UsageError check inside the Exception block already catches BadParameter (it inherits from UsageError) — the separate typer.BadParameter handler was redundant. Added an in-process Behave step that calls main() directly and captures err_console output, plus a scenario that runs `plan use --no-such-flag` to cover the UsageError branch (subprocess steps do not count toward unit-test coverage).
44 lines
1.7 KiB
Gherkin
44 lines
1.7 KiB
Gherkin
Feature: CLI main() error handling paths
|
|
As a developer
|
|
I want to cover the error-handling branches in cleveragents.cli.main
|
|
So that convert_exit_code(), subcommand import failure, and config validation are exercised
|
|
|
|
@coverage
|
|
Scenario: invalid --config-path that is a directory is rejected
|
|
When I run CLI with arguments ["--config-path", "/tmp", "version"]
|
|
Then the main cli exit code should be 1
|
|
And the main cli output contains "is not a file"
|
|
|
|
@coverage
|
|
Scenario: unknown command returns exit code 2
|
|
When I run CLI with arguments ["this_is_not_a_command"]
|
|
Then the main cli exit code should be 2
|
|
And the main cli output contains "Invalid command 'this_is_not_a_command'"
|
|
|
|
# These tests call convert_exit_code and _print_basic_help directly
|
|
@coverage
|
|
Scenario: convert_exit_code(None) returns 0
|
|
When the main exit-code converter is called with the value "None"
|
|
Then the main convert_exit_code result is "0"
|
|
|
|
@coverage
|
|
Scenario: convert_exit_code(int -1) returns -1 for negative codes
|
|
When the main exit-code converter is called with the value "-1"
|
|
Then the main convert_exit_code result is "-1"
|
|
|
|
@coverage
|
|
Scenario: convert_exit_code(string "abc") returns 1 for unparseable
|
|
When the main exit-code converter is called with the value "abc"
|
|
Then the main convert_exit_code result is "1"
|
|
|
|
@coverage
|
|
Scenario: _print_basic_help prints without error
|
|
When I call the main _print_basic_help
|
|
Then the main _print_basic_help completes ok
|
|
|
|
@coverage
|
|
Scenario: unknown option triggers UsageError handler with exit code 2
|
|
When I call main with arguments ["plan", "use", "--no-such-flag", "x"]
|
|
Then the main cli exit code should be 2
|
|
And the main cli output contains "No such option"
|