From e3269be343afe173549106c5fbc8eb9c3e492d76 Mon Sep 17 00:00:00 2001 From: SRetip Date: Mon, 25 Mar 2024 12:52:08 +0200 Subject: [PATCH 1/2] fix & add test --- .../src/action/readme_health_table_renew.rs | 14 ++++++++------ .../move/willbe/tests/inc/action/cicd_renew.rs | 16 ++++++++++++++-- .../inc/action/readme_modules_headers_renew.rs | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/module/move/willbe/src/action/readme_health_table_renew.rs b/module/move/willbe/src/action/readme_health_table_renew.rs index d1e5671597..7f15f4dda4 100644 --- a/module/move/willbe/src/action/readme_health_table_renew.rs +++ b/module/move/willbe/src/action/readme_health_table_renew.rs @@ -356,7 +356,9 @@ mod private let mut rou = format!( "| [{}]({}/{}) |", &module_name, &table_parameters.base_path, &module_name ); if table_parameters.include_stability { - rou.push_str( &stability_generate( &stability.as_ref().unwrap() ) ); + let mut stability = stability_generate( &stability.as_ref().unwrap() ); + stability.push_str( " |" ); + rou.push_str( &stability ); } if parameters.branches.is_some() && table_parameters.include_branches { @@ -378,11 +380,11 @@ mod private { match stability { - Stability::Experimental => " [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) |".into(), - Stability::Stable => " [![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable) |".into(), - Stability::Deprecated => " [![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) |".into(), - Stability::Unstable => " [![stability-unstable](https://img.shields.io/badge/stability-unstable-yellow.svg)](https://github.com/emersion/stability-badges#unstable) |".into(), - Stability::Frozen => " [![stability-frozen](https://img.shields.io/badge/stability-frozen-blue.svg)](https://github.com/emersion/stability-badges#frozen) |".into(), + Stability::Experimental => " [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental)".into(), + Stability::Stable => " [![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable)".into(), + Stability::Deprecated => " [![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated)".into(), + Stability::Unstable => " [![stability-unstable](https://img.shields.io/badge/stability-unstable-yellow.svg)](https://github.com/emersion/stability-badges#unstable)".into(), + Stability::Frozen => " [![stability-frozen](https://img.shields.io/badge/stability-frozen-blue.svg)](https://github.com/emersion/stability-badges#frozen)".into(), } } diff --git a/module/move/willbe/tests/inc/action/cicd_renew.rs b/module/move/willbe/tests/inc/action/cicd_renew.rs index 497e08b1b4..1249989cf5 100644 --- a/module/move/willbe/tests/inc/action/cicd_renew.rs +++ b/module/move/willbe/tests/inc/action/cicd_renew.rs @@ -31,7 +31,7 @@ fn arrange( sample_dir : &str ) -> assert_fs::TempDir struct Workflow { name : String, - on : String, + on : HashMap>>, env : HashMap< String, String >, jobs : HashMap< String, Job >, } @@ -72,7 +72,18 @@ fn default_case() let expected = Workflow { name : "test_module".into(), - on : "push".into(), + on : + { + let mut map = HashMap::new(); + let mut push_map = HashMap::new(); + push_map.insert + ( + "branches-ignore".to_string(), + vec![ "alpha".to_string(), "beta".to_string(), "master".to_string() ], + ); + map.insert( "push".to_string(), push_map ); + map + }, env : HashMap::from_iter( [ ( "CARGO_TERM_COLOR".to_string(), "always".to_string() ) ] ), jobs : HashMap::from_iter( [ ( "test".to_string(), job ) ] ), }; @@ -84,6 +95,7 @@ fn default_case() let mut file = File::open( file_path ).unwrap(); let mut content = String::new(); _ = file.read_to_string( &mut content ).unwrap(); + dbg!(&content); let actual: Workflow = serde_yaml::from_str( &content ).unwrap(); assert_eq!( expected, actual ); diff --git a/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs b/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs index df61049bf9..3b731914bb 100644 --- a/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs @@ -56,6 +56,7 @@ fn default_stability() // Assert assert!( actual.contains( "[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental)" ) ); + assert!( !actual.contains( "|" ) ); } #[ test ] From 52418167705a04fd75eeed260d55f488cbd74d84 Mon Sep 17 00:00:00 2001 From: SRetip Date: Mon, 25 Mar 2024 13:00:13 +0200 Subject: [PATCH 2/2] remove dbg --- module/move/willbe/tests/inc/action/cicd_renew.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/module/move/willbe/tests/inc/action/cicd_renew.rs b/module/move/willbe/tests/inc/action/cicd_renew.rs index 1249989cf5..ddd92bb908 100644 --- a/module/move/willbe/tests/inc/action/cicd_renew.rs +++ b/module/move/willbe/tests/inc/action/cicd_renew.rs @@ -95,7 +95,6 @@ fn default_case() let mut file = File::open( file_path ).unwrap(); let mut content = String::new(); _ = file.read_to_string( &mut content ).unwrap(); - dbg!(&content); let actual: Workflow = serde_yaml::from_str( &content ).unwrap(); assert_eq!( expected, actual );