@@ -8,21 +8,23 @@ use crate::presentation::commands::create;
88#[ test]
99fn it_should_generate_template_with_default_path ( ) {
1010 let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
11-
11+
1212 // Change to temp directory so template is created there
1313 let original_dir = std:: env:: current_dir ( ) . unwrap ( ) ;
1414 std:: env:: set_current_dir ( temp_dir. path ( ) ) . unwrap ( ) ;
1515
16- let action = CreateAction :: Template {
17- output_path : None ,
18- } ;
16+ let action = CreateAction :: Template { output_path : None } ;
1917
2018 let result = create:: handle_create_command ( action, temp_dir. path ( ) ) ;
21-
19+
2220 // Restore original directory
2321 std:: env:: set_current_dir ( original_dir) . unwrap ( ) ;
2422
25- assert ! ( result. is_ok( ) , "Template generation should succeed: {:?}" , result. err( ) ) ;
23+ assert ! (
24+ result. is_ok( ) ,
25+ "Template generation should succeed: {:?}" ,
26+ result. err( )
27+ ) ;
2628
2729 // Verify file exists at default path
2830 let template_path = temp_dir. path ( ) . join ( "environment-template.json" ) ;
@@ -34,8 +36,8 @@ fn it_should_generate_template_with_default_path() {
3436
3537 // Verify file content is valid JSON
3638 let content = std:: fs:: read_to_string ( & template_path) . unwrap ( ) ;
37- let parsed: serde_json:: Value = serde_json :: from_str ( & content )
38- . expect ( "Template should be valid JSON" ) ;
39+ let parsed: serde_json:: Value =
40+ serde_json :: from_str ( & content ) . expect ( "Template should be valid JSON" ) ;
3941
4042 // Verify structure
4143 assert ! ( parsed[ "environment" ] [ "name" ] . is_string( ) ) ;
@@ -87,12 +89,21 @@ fn it_should_generate_valid_json_template() {
8789 assert ! ( parsed. is_object( ) ) ;
8890 assert ! ( parsed[ "environment" ] . is_object( ) ) ;
8991 assert ! ( parsed[ "ssh_credentials" ] . is_object( ) ) ;
90-
92+
9193 // Verify placeholder values
92- assert_eq ! ( parsed[ "environment" ] [ "name" ] , "REPLACE_WITH_ENVIRONMENT_NAME" ) ;
93- assert_eq ! ( parsed[ "ssh_credentials" ] [ "private_key_path" ] , "REPLACE_WITH_SSH_PRIVATE_KEY_PATH" ) ;
94- assert_eq ! ( parsed[ "ssh_credentials" ] [ "public_key_path" ] , "REPLACE_WITH_SSH_PUBLIC_KEY_PATH" ) ;
95-
94+ assert_eq ! (
95+ parsed[ "environment" ] [ "name" ] ,
96+ "REPLACE_WITH_ENVIRONMENT_NAME"
97+ ) ;
98+ assert_eq ! (
99+ parsed[ "ssh_credentials" ] [ "private_key_path" ] ,
100+ "REPLACE_WITH_SSH_PRIVATE_KEY_PATH"
101+ ) ;
102+ assert_eq ! (
103+ parsed[ "ssh_credentials" ] [ "public_key_path" ] ,
104+ "REPLACE_WITH_SSH_PUBLIC_KEY_PATH"
105+ ) ;
106+
96107 // Verify default values
97108 assert_eq ! ( parsed[ "ssh_credentials" ] [ "username" ] , "torrust" ) ;
98109 assert_eq ! ( parsed[ "ssh_credentials" ] [ "port" ] , 22 ) ;
@@ -101,7 +112,12 @@ fn it_should_generate_valid_json_template() {
101112#[ test]
102113fn it_should_create_parent_directories ( ) {
103114 let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
104- let deep_path = temp_dir. path ( ) . join ( "a" ) . join ( "b" ) . join ( "c" ) . join ( "template.json" ) ;
115+ let deep_path = temp_dir
116+ . path ( )
117+ . join ( "a" )
118+ . join ( "b" )
119+ . join ( "c" )
120+ . join ( "template.json" ) ;
105121
106122 let action = CreateAction :: Template {
107123 output_path : Some ( deep_path. clone ( ) ) ,
@@ -110,6 +126,12 @@ fn it_should_create_parent_directories() {
110126 let result = create:: handle_create_command ( action, temp_dir. path ( ) ) ;
111127
112128 assert ! ( result. is_ok( ) , "Should create parent directories" ) ;
113- assert ! ( deep_path. exists( ) , "Template should be created at deep path" ) ;
114- assert ! ( deep_path. parent( ) . unwrap( ) . exists( ) , "Parent directories should exist" ) ;
129+ assert ! (
130+ deep_path. exists( ) ,
131+ "Template should be created at deep path"
132+ ) ;
133+ assert ! (
134+ deep_path. parent( ) . unwrap( ) . exists( ) ,
135+ "Parent directories should exist"
136+ ) ;
115137}
0 commit comments