11use ron:: from_str;
22
3- use crate :: cli:: common:: args:: {
4- InputConfig ,
5- OutputConfig ,
6- } ;
3+ use crate :: cli:: common:: args:: OutputConfig ;
74use crate :: cli:: flow:: args:: FlowArgs ;
85use crate :: cli:: utils:: output_formatter:: OutputFormatter ;
96use crate :: cli:: version:: args:: VersionArgs ;
107use crate :: cli:: version:: pipeline:: run_version_pipeline;
118use crate :: error:: ZervError ;
12- use crate :: utils:: constants:: * ;
139
1410/// Main flow pipeline handler
1511///
@@ -28,11 +24,7 @@ pub fn run_flow_pipeline(args: FlowArgs) -> Result<String, ZervError> {
2824 // For now, just call version command with zerv output format
2925 // TODO: Phase 2+ - Translate flow arguments to version arguments
3026 let version_args = VersionArgs {
31- input : InputConfig {
32- source : sources:: GIT . to_string ( ) ,
33- input_format : "auto" . to_string ( ) ,
34- directory : None ,
35- } ,
27+ input : args. input . clone ( ) ,
3628 output : OutputConfig {
3729 output_format : "zerv" . to_string ( ) ,
3830 output_template : None ,
@@ -64,66 +56,74 @@ pub fn run_flow_pipeline(args: FlowArgs) -> Result<String, ZervError> {
6456#[ cfg( test) ]
6557mod tests {
6658 use super :: * ;
59+ use crate :: test_utils:: {
60+ GitRepoFixture ,
61+ assert_version_expectation,
62+ should_run_docker_tests,
63+ } ;
6764
68- #[ test]
69- fn test_run_flow_pipeline_basic ( ) {
70- let args = FlowArgs :: default ( ) ;
71- let result = run_flow_pipeline ( args) ;
72- // Should work now (assuming git repo exists)
73- // Note: This test may fail in environments without git
74- match result {
75- Ok ( _) => { } // Success
76- Err ( ZervError :: VcsNotFound ( _) ) => {
77- // Expected in test environments without git
78- }
79- Err ( e) => {
80- panic ! ( "Unexpected error: {:?}" , e) ;
81- }
82- }
83- }
84-
85- #[ test]
86- fn test_run_flow_pipeline_different_output_formats ( ) {
87- let formats = [ "semver" , "pep440" , "zerv" ] ;
65+ fn test_flow_pipeline_with_fixture (
66+ fixture_path : & str ,
67+ semver_expectation : & str ,
68+ pep440_expectation : & str ,
69+ ) {
70+ let test_cases = vec ! [
71+ ( "semver" , semver_expectation) ,
72+ ( "pep440" , pep440_expectation) ,
73+ ] ;
8874
89- for format in formats . iter ( ) {
75+ for ( format_name , expectation ) in test_cases {
9076 let mut args = FlowArgs :: default ( ) ;
91- args. output . output_format = format. to_string ( ) ;
77+ args. input . directory = Some ( fixture_path. to_string ( ) ) ;
78+ args. output . output_format = format_name. to_string ( ) ;
9279
9380 let result = run_flow_pipeline ( args) ;
94- match result {
95- Ok ( _) => { } // Success
96- Err ( ZervError :: VcsNotFound ( _) ) => {
97- // Expected in test environments without git
98- }
99- Err ( e) => {
100- panic ! ( "Unexpected error for format '{}': {:?}" , format, e) ;
101- }
102- }
81+ assert ! (
82+ result. is_ok( ) ,
83+ "Flow pipeline should succeed with {} format at {}" ,
84+ format_name,
85+ fixture_path
86+ ) ;
87+ let output = result. unwrap ( ) ;
88+ assert ! (
89+ !output. is_empty( ) ,
90+ "Flow pipeline should produce output for {} format" ,
91+ format_name
92+ ) ;
93+
94+ assert_version_expectation ( expectation, & output) ;
95+
96+ println ! ( "✓ Flow pipeline output ({}): {}" , format_name, output) ;
10397 }
10498 }
10599
106100 #[ test]
107- fn test_run_flow_pipeline_with_output_prefix ( ) {
108- let mut args = FlowArgs :: default ( ) ;
109- args. output . output_prefix = Some ( "v" . to_string ( ) ) ;
110-
111- let result = run_flow_pipeline ( args) ;
112- match result {
113- Ok ( output) => {
114- // Output should start with the prefix
115- assert ! (
116- output. starts_with( 'v' ) ,
117- "Output should start with prefix 'v': {}" ,
118- output
119- ) ;
120- }
121- Err ( ZervError :: VcsNotFound ( _) ) => {
122- // Expected in test environments without git
123- }
124- Err ( e) => {
125- panic ! ( "Unexpected error: {:?}" , e) ;
126- }
101+ fn test_trunk_based_development_flow ( ) {
102+ if !should_run_docker_tests ( ) {
103+ return ; // Skip when `ZERV_TEST_DOCKER` are disabled
127104 }
105+
106+ // Step 1: Start with a clean tag
107+ let fixture =
108+ GitRepoFixture :: tagged ( "v1.0.0" ) . expect ( "Failed to create git fixture with tag" ) ;
109+ let fixture_path = fixture. path ( ) . to_string_lossy ( ) ;
110+
111+ test_flow_pipeline_with_fixture ( & fixture_path, r"1.0.0" , r"1.0.0" ) ;
112+
113+ // Step 2: Checkout feature branch
114+ fixture
115+ . checkout_branch ( "feature-1" )
116+ . expect ( "Failed to checkout feature-1 branch" ) ;
117+
118+ test_flow_pipeline_with_fixture ( & fixture_path, r"1.0.0" , r"1.0.0" ) ;
119+
120+ // Step 3: Make dirty working directory
121+ fixture. make_dirty ( ) . expect ( "Failed to make fixture dirty" ) ;
122+
123+ test_flow_pipeline_with_fixture (
124+ & fixture_path,
125+ r"1.0.0+feature.1.0.{{commit_hash_7}}" ,
126+ r"1.0.0+feature.1.0.{{commit_hash_7}}" ,
127+ ) ;
128128 }
129129}
0 commit comments