Skip to content

Commit 98b7935

Browse files
committed
test: improve cli test coverage
1. Add test for empty release name error 2. Add test for already initialized error 3. Achieve 100% coverage for CLI error handling This ensures all error paths are properly tested and maintains our high test coverage standards.
1 parent 51334b8 commit 98b7935

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/unit/test_cli.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,26 @@ def test_init_command(tmp_path):
4242
with config_file.open() as file:
4343
config_data = json.load(file)
4444
assert config_data == {"version": "1.0", "release": "test-release", "deployments": {}, "config": []}
45+
46+
47+
def test_init_command_empty_release():
48+
"""Test init command with empty release name."""
49+
result = runner.invoke(app, ["init", "--release", ""])
50+
assert result.exit_code == 1
51+
assert "Failed to initialize: Release name cannot be empty" in result.stdout
52+
53+
54+
def test_init_command_already_initialized(tmp_path):
55+
"""Test init command when config already exists."""
56+
# Change to temp directory
57+
os.chdir(tmp_path)
58+
59+
# First initialization
60+
result = runner.invoke(app, ["init", "--release", "test-release"])
61+
assert result.exit_code == 0
62+
63+
# Try to initialize again
64+
result = runner.invoke(app, ["init", "--release", "another-release"])
65+
assert result.exit_code == 1
66+
assert "Failed to initialize: Configuration file" in result.stdout
67+
assert "already exists" in result.stdout

0 commit comments

Comments
 (0)