This repository was archived by the owner on Dec 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -411,8 +411,10 @@ impl State<PodState> for CreatingConfig {
411411#[ cfg( test) ]
412412mod tests {
413413 use super :: * ;
414+ use rstest:: rstest;
414415 use std:: collections:: BTreeMap ;
415416 use std:: path:: PathBuf ;
417+ use std:: str:: FromStr ;
416418
417419 #[ test]
418420 fn test_render_template ( ) {
@@ -445,4 +447,25 @@ mod tests {
445447 let legal_path_string = CreatingConfig :: pathbuf_to_string ( "testfield" , legal_path) . unwrap ( ) ;
446448 assert_eq ! ( input_path_string, legal_path_string) ;
447449 }
450+
451+ #[ rstest]
452+ #[ case( "{{packageroot}}/test" , "/opt/stackable/packages/test" ) ]
453+ #[ case( "/test" , "/test" ) ]
454+ #[ case( "test" , "/etc/stackable/config/test" ) ]
455+ fn test_create_config_path ( #[ case] input : & str , #[ case] expected_output : & str ) {
456+ let mut template_data: BTreeMap < String , String > = BTreeMap :: new ( ) ;
457+
458+ template_data. insert (
459+ "packageroot" . to_string ( ) ,
460+ "/opt/stackable/packages" . to_string ( ) ,
461+ ) ;
462+
463+ let config_dir = PathBuf :: from_str ( "/etc/stackable/config" ) . unwrap ( ) ;
464+
465+ let output = config_dir
466+ . join ( & CreatingConfig :: render_config_template ( & template_data, input) . unwrap ( ) ) ;
467+
468+ let output = output. to_string_lossy ( ) ;
469+ assert_eq ! ( output, expected_output) ;
470+ }
448471}
You can’t perform that action at this time.
0 commit comments