@@ -15,7 +15,7 @@ class TestManifestValidateCommand:
1515 """Test cases for the manifest validate command."""
1616
1717 def test_validate_valid_manifest_up_to_date (self , tmp_path : Path ) -> None :
18- """Test validate command with a valid, up-to-date manifest (exit code 1 - needs migration )."""
18+ """Test validate command with a valid manifest that needs migration (exit code 0 without --strict, 1 with --strict )."""
1919 manifest_content = {
2020 "version" : "0.29.0" ,
2121 "type" : "DeclarativeSource" ,
@@ -46,16 +46,23 @@ def test_validate_valid_manifest_up_to_date(self, tmp_path: Path) -> None:
4646 yaml .dump (manifest_content , f )
4747
4848 runner = CliRunner ()
49+
4950 result = runner .invoke (
5051 manifest_cli_group , ["validate" , "--manifest-path" , str (manifest_file )]
5152 )
53+ assert result .exit_code == 0
54+ assert "✅ Manifest" in result .output
55+ assert "is valid and up to date" in result .output
5256
53- assert result .exit_code == 1
54- assert "⚠️" in result .output
55- assert "could benefit from migration" in result .output
57+ result_strict = runner .invoke (
58+ manifest_cli_group , ["validate" , "--manifest-path" , str (manifest_file ), "--strict" ]
59+ )
60+ assert result_strict .exit_code == 1
61+ assert "⚠️" in result_strict .output
62+ assert "could benefit from migration" in result_strict .output
5663
5764 def test_validate_manifest_needs_migration (self , tmp_path : Path ) -> None :
58- """Test validate command with manifest that needs migration (exit code 1 )."""
65+ """Test validate command with manifest that needs migration (exit code 0 without --strict, 1 with --strict )."""
5966 manifest_content = {
6067 "version" : "0.1.0" ,
6168 "type" : "DeclarativeSource" ,
@@ -86,16 +93,23 @@ def test_validate_manifest_needs_migration(self, tmp_path: Path) -> None:
8693 yaml .dump (manifest_content , f )
8794
8895 runner = CliRunner ()
96+
8997 result = runner .invoke (
9098 manifest_cli_group , ["validate" , "--manifest-path" , str (manifest_file )]
9199 )
100+ assert result .exit_code == 0
101+ assert "✅ Manifest" in result .output
102+ assert "is valid and up to date" in result .output
92103
93- assert result .exit_code == 1
94- assert "⚠️" in result .output
95- assert "could benefit from migration" in result .output
104+ result_strict = runner .invoke (
105+ manifest_cli_group , ["validate" , "--manifest-path" , str (manifest_file ), "--strict" ]
106+ )
107+ assert result_strict .exit_code == 1
108+ assert "⚠️" in result_strict .output
109+ assert "could benefit from migration" in result_strict .output
96110
97111 def test_validate_manifest_unfixable_validation_errors (self , tmp_path : Path ) -> None :
98- """Test validate command with unfixable validation errors (exit code 3 )."""
112+ """Test validate command with unfixable validation errors (exit code 2 )."""
99113 manifest_content = {
100114 "version" : "0.29.0" ,
101115 "type" : "DeclarativeSource" ,
@@ -129,12 +143,12 @@ def test_validate_manifest_unfixable_validation_errors(self, tmp_path: Path) ->
129143 manifest_cli_group , ["validate" , "--manifest-path" , str (manifest_file )]
130144 )
131145
132- assert result .exit_code == 3
146+ assert result .exit_code == 2
133147 assert "❌ Validation failed" in result .output
134148 assert "'check' is a required property" in result .output
135149
136150 def test_validate_manifest_file_not_found (self , tmp_path : Path ) -> None :
137- """Test validate command with non-existent manifest file (exit code 2)."""
151+ """Test validate command with non-existent manifest file (exit code 2 from Click )."""
138152 runner = CliRunner ()
139153 result = runner .invoke (
140154 manifest_cli_group , ["validate" , "--manifest-path" , str (tmp_path / "nonexistent.yaml" )]
@@ -145,7 +159,7 @@ def test_validate_manifest_file_not_found(self, tmp_path: Path) -> None:
145159 assert "does not exist" in result .output
146160
147161 def test_validate_manifest_invalid_yaml (self , tmp_path : Path ) -> None :
148- """Test validate command with invalid YAML (exit code 1 )."""
162+ """Test validate command with invalid YAML (exit code 3 )."""
149163 manifest_file = tmp_path / "manifest.yaml"
150164 with open (manifest_file , "w" ) as f :
151165 f .write ("invalid: yaml: content: [" )
@@ -155,11 +169,21 @@ def test_validate_manifest_invalid_yaml(self, tmp_path: Path) -> None:
155169 manifest_cli_group , ["validate" , "--manifest-path" , str (manifest_file )]
156170 )
157171
158- assert result .exit_code == 1
172+ assert result .exit_code == 3
159173 assert "❌ Error: Invalid YAML" in result .output
160174
175+ def test_validate_manifest_strict_flag_help (self , tmp_path : Path ) -> None :
176+ """Test that the --strict flag appears in help text."""
177+ runner = CliRunner ()
178+ result = runner .invoke (manifest_cli_group , ["validate" , "--help" ])
179+
180+ assert result .exit_code == 0
181+ assert "--strict" in result .output
182+ assert "Enable strict mode" in result .output
183+
184+
161185 def test_validate_manifest_not_dict (self , tmp_path : Path ) -> None :
162- """Test validate command with YAML that's not a dictionary (exit code 1 )."""
186+ """Test validate command with YAML that's not a dictionary (exit code 3 )."""
163187 manifest_file = tmp_path / "manifest.yaml"
164188 with open (manifest_file , "w" ) as f :
165189 yaml .dump (["not" , "a" , "dict" ], f )
@@ -169,7 +193,7 @@ def test_validate_manifest_not_dict(self, tmp_path: Path) -> None:
169193 manifest_cli_group , ["validate" , "--manifest-path" , str (manifest_file )]
170194 )
171195
172- assert result .exit_code == 1
196+ assert result .exit_code == 3
173197 assert "❌ Error: Manifest file" in result .output
174198 assert "does not contain a valid YAML dictionary" in result .output
175199
@@ -310,7 +334,7 @@ def test_migrate_manifest_dry_run(self, tmp_path: Path) -> None:
310334 assert unchanged_content == original_content
311335
312336 def test_migrate_manifest_file_not_found (self , tmp_path : Path ) -> None :
313- """Test migrate command with non-existent manifest file (exit code 2)."""
337+ """Test migrate command with non-existent manifest file (exit code 2 from Click )."""
314338 runner = CliRunner ()
315339 result = runner .invoke (
316340 manifest_cli_group , ["migrate" , "--manifest-path" , str (tmp_path / "nonexistent.yaml" )]
@@ -321,7 +345,7 @@ def test_migrate_manifest_file_not_found(self, tmp_path: Path) -> None:
321345 assert "does not exist" in result .output
322346
323347 def test_migrate_manifest_invalid_yaml (self , tmp_path : Path ) -> None :
324- """Test migrate command with invalid YAML (exit code 1 )."""
348+ """Test migrate command with invalid YAML (exit code 3 )."""
325349 manifest_file = tmp_path / "manifest.yaml"
326350 with open (manifest_file , "w" ) as f :
327351 f .write ("invalid: yaml: content: [" )
@@ -331,11 +355,11 @@ def test_migrate_manifest_invalid_yaml(self, tmp_path: Path) -> None:
331355 manifest_cli_group , ["migrate" , "--manifest-path" , str (manifest_file )]
332356 )
333357
334- assert result .exit_code == 1
358+ assert result .exit_code == 3
335359 assert "❌ Error: Invalid YAML" in result .output
336360
337361 def test_migrate_manifest_not_dict (self , tmp_path : Path ) -> None :
338- """Test migrate command with YAML that's not a dictionary (exit code 1 )."""
362+ """Test migrate command with YAML that's not a dictionary (exit code 3 )."""
339363 manifest_file = tmp_path / "manifest.yaml"
340364 with open (manifest_file , "w" ) as f :
341365 yaml .dump (["not" , "a" , "dict" ], f )
@@ -345,7 +369,7 @@ def test_migrate_manifest_not_dict(self, tmp_path: Path) -> None:
345369 manifest_cli_group , ["migrate" , "--manifest-path" , str (manifest_file )]
346370 )
347371
348- assert result .exit_code == 1
372+ assert result .exit_code == 3
349373 assert "❌ Error: Manifest file" in result .output
350374 assert "does not contain a valid YAML dictionary" in result .output
351375
@@ -370,10 +394,10 @@ def test_validate_command_help(self) -> None:
370394
371395 assert result .exit_code == 0
372396 assert "codes:" in result .output
373- assert "0: Manifest is valid and up to date" in result .output
374- assert "1: Manifest is valid but needs " in result .output
375- assert "2: Manifest has validation errors that are " in result .output
376- assert "3: Manifest has validation errors that are NOT fixable " in result .output
397+ assert "0:" in result . output and " valid and up to date" in result .output
398+ assert "1:" in result . output and "fixable via migration " in result .output
399+ assert "2:" in result . output and "NOT fixable via migration " in result .output
400+ assert "3:" in result . output and "General errors " in result .output
377401
378402 def test_migrate_command_help (self ) -> None :
379403 """Test that the migrate command shows help correctly."""
0 commit comments