@@ -328,27 +328,6 @@ mod template_complex_scenarios {
328328 }
329329}
330330
331- mod template_with_output_prefix {
332- use super :: * ;
333-
334- #[ rstest]
335- #[ case:: v_prefix( "v" , "v1.2.3" ) ]
336- #[ case:: custom_prefix( "Release-" , "Release-1.2.3" ) ]
337- fn test_prefix_flag ( #[ case] prefix : & str , #[ case] expected : & str ) {
338- let fixture = ZervFixture :: new ( ) . with_version ( 1 , 2 , 3 ) ;
339- let zerv_ron = fixture. build ( ) . to_string ( ) ;
340-
341- let output = TestCommand :: new ( )
342- . args_from_str ( format ! (
343- "version --source stdin --output-template '{{{{major}}}}.{{{{minor}}}}.{{{{patch}}}}' --output-prefix {prefix}"
344- ) )
345- . stdin ( zerv_ron)
346- . assert_success ( ) ;
347-
348- assert_eq ! ( output. stdout( ) . trim( ) , expected) ;
349- }
350- }
351-
352331mod template_edge_cases {
353332 use super :: * ;
354333
@@ -399,23 +378,50 @@ mod template_with_schema {
399378 "Template should override schema output"
400379 ) ;
401380 }
381+ }
382+
383+ mod template_validation_errors {
384+ use super :: * ;
402385
403386 #[ test]
404- fn test_template_with_format ( ) {
405- let fixture = ZervFixture :: new ( )
406- . with_version ( 1 , 2 , 3 )
407- . with_pre_release ( PreReleaseLabel :: Alpha , Some ( 1 ) ) ;
387+ fn test_template_conflicts_with_output_format ( ) {
388+ let fixture = ZervFixture :: new ( ) . with_version ( 1 , 2 , 3 ) ;
408389 let zerv_ron = fixture. build ( ) . to_string ( ) ;
409390
410391 let output = TestCommand :: new ( )
411- . args_from_str ( "version --source stdin --output-format pep440 --output-template 'Custom: {{pep440 }}'" )
392+ . args_from_str ( "version --source stdin --output-format pep440 --output-template '{{major}}.{{minor}}.{{patch }}'" )
412393 . stdin ( zerv_ron)
413- . assert_success ( ) ;
394+ . assert_failure ( ) ;
414395
415- assert_eq ! (
416- output. stdout( ) . trim( ) ,
417- "Custom: 1.2.3a1" ,
418- "Template should use formatted version variable"
396+ let stderr = output. stderr ( ) ;
397+ assert ! (
398+ stderr. contains( "Cannot use --output-template with --output-format" ) ,
399+ "Should error when using --output-template with --output-format. Got stderr: {stderr}"
400+ ) ;
401+ assert ! (
402+ stderr. contains( "Use --output-format alone for pure format output" ) ,
403+ "Error message should explain the distinction between format and template. Got stderr: {stderr}"
404+ ) ;
405+ }
406+
407+ #[ test]
408+ fn test_template_conflicts_with_output_prefix ( ) {
409+ let fixture = ZervFixture :: new ( ) . with_version ( 1 , 2 , 3 ) ;
410+ let zerv_ron = fixture. build ( ) . to_string ( ) ;
411+
412+ let output = TestCommand :: new ( )
413+ . args_from_str ( "version --source stdin --output-template '{{major}}.{{minor}}.{{patch}}' --output-prefix v" )
414+ . stdin ( zerv_ron)
415+ . assert_failure ( ) ;
416+
417+ let stderr = output. stderr ( ) ;
418+ assert ! (
419+ stderr. contains( "Cannot use --output-template with --output-prefix" ) ,
420+ "Should error when using --output-template with --output-prefix. Got stderr: {stderr}"
421+ ) ;
422+ assert ! (
423+ stderr. contains( "Add the prefix directly in your template" ) ,
424+ "Error message should suggest adding prefix in template. Got stderr: {stderr}"
419425 ) ;
420426 }
421427}
0 commit comments