11//! Integration tests for `cargo rail init` command
22
3- use crate :: helpers:: { load_rail_config , run_cargo_rail , TestWorkspace } ;
3+ use crate :: helpers:: { TestWorkspace , load_rail_config , run_cargo_rail } ;
44use anyhow:: Result ;
55
66#[ test]
@@ -19,7 +19,7 @@ fn test_init_creates_config() -> Result<()> {
1919 assert ! ( config_path. exists( ) , "config file should be created" ) ;
2020
2121 // Verify config is valid TOML and contains expected sections
22- let config_content = std:: fs:: read_to_string ( & config_path) ?;
22+ let config_content = std:: fs:: read_to_string ( config_path) ?;
2323 assert ! ( config_content. contains( "[workspace]" ) ) ;
2424 assert ! ( config_content. contains( "[toolchain]" ) ) ;
2525 assert ! ( config_content. contains( "[unify]" ) ) ;
@@ -69,7 +69,7 @@ fn test_init_detects_toolchain() -> Result<()> {
6969
7070 // Create rust-toolchain.toml with specific version
7171 std:: fs:: write (
72- & ws. path . join ( "rust-toolchain.toml" ) ,
72+ ws. path . join ( "rust-toolchain.toml" ) ,
7373 r#"[toolchain]
7474channel = "1.76.0"
7575profile = "minimal"
@@ -81,7 +81,7 @@ components = ["clippy", "rustfmt"]
8181 run_cargo_rail ( & ws. path , & [ "rail" , "init" , "--non-interactive" ] ) ?;
8282
8383 // Verify config detects toolchain
84- let config_content = std:: fs:: read_to_string ( & ws. path . join ( ".config/rail.toml" ) ) ?;
84+ let config_content = std:: fs:: read_to_string ( ws. path . join ( ".config/rail.toml" ) ) ?;
8585 assert ! (
8686 config_content. contains( "channel = \" 1.76.0\" " ) ,
8787 "should detect channel from rust-toolchain.toml"
@@ -105,20 +105,17 @@ fn test_init_detects_policy_from_cargo_toml() -> Result<()> {
105105
106106 // Update workspace Cargo.toml to add rust-version to existing workspace.package
107107 let cargo_toml = & ws. path . join ( "Cargo.toml" ) ;
108- let existing_content = std:: fs:: read_to_string ( & cargo_toml) ?;
108+ let existing_content = std:: fs:: read_to_string ( cargo_toml) ?;
109109
110110 // Add rust-version to existing [workspace.package] section
111- let new_content = existing_content. replace (
112- "edition = \" 2021\" " ,
113- "edition = \" 2021\" \n rust-version = \" 1.75.0\" " ,
114- ) ;
115- std:: fs:: write ( & cargo_toml, new_content) ?;
111+ let new_content = existing_content. replace ( "edition = \" 2021\" " , "edition = \" 2021\" \n rust-version = \" 1.75.0\" " ) ;
112+ std:: fs:: write ( cargo_toml, new_content) ?;
116113
117114 // Run init
118115 run_cargo_rail ( & ws. path , & [ "rail" , "init" , "--non-interactive" ] ) ?;
119116
120117 // Verify config detects policy
121- let config_content = std:: fs:: read_to_string ( & ws. path . join ( ".config/rail.toml" ) ) ?;
118+ let config_content = std:: fs:: read_to_string ( ws. path . join ( ".config/rail.toml" ) ) ?;
122119 assert ! (
123120 config_content. contains( "resolver = \" 2\" " ) ,
124121 "should detect resolver from Cargo.toml"
@@ -221,9 +218,9 @@ fn test_init_generated_config_is_valid() -> Result<()> {
221218 assert_eq ! ( config. workspace. root. to_str( ) . unwrap( ) , "." ) ;
222219 assert_eq ! ( config. toolchain. channel, "stable" ) ;
223220 assert_eq ! ( config. toolchain. profile, "default" ) ;
224- assert_eq ! ( config. unify. use_all_features, true ) ;
225- assert_eq ! ( config. unify. sync_on_unify, true ) ;
226- assert_eq ! ( config. security. require_signed_commits, false ) ;
221+ assert ! ( config. unify. use_all_features) ;
222+ assert ! ( config. unify. sync_on_unify) ;
223+ assert ! ( ! config. security. require_signed_commits) ;
227224 assert_eq ! ( config. security. protected_branches, vec![ "main" , "master" ] ) ;
228225
229226 Ok ( ( ) )
@@ -235,13 +232,13 @@ fn test_init_with_rust_toolchain_plain_file() -> Result<()> {
235232 ws. remove_config ( ) ?; // Remove default config for init test
236233
237234 // Create plain rust-toolchain file (no .toml extension)
238- std:: fs:: write ( & ws. path . join ( "rust-toolchain" ) , "1.80.0\n " ) ?;
235+ std:: fs:: write ( ws. path . join ( "rust-toolchain" ) , "1.80.0\n " ) ?;
239236
240237 // Run init
241238 run_cargo_rail ( & ws. path , & [ "rail" , "init" , "--non-interactive" ] ) ?;
242239
243240 // Verify config detects channel
244- let config_content = std:: fs:: read_to_string ( & ws. path . join ( ".config/rail.toml" ) ) ?;
241+ let config_content = std:: fs:: read_to_string ( ws. path . join ( ".config/rail.toml" ) ) ?;
245242 assert ! (
246243 config_content. contains( "channel = \" 1.80.0\" " ) ,
247244 "should detect channel from rust-toolchain file"
@@ -258,7 +255,7 @@ fn test_init_all_fields_present() -> Result<()> {
258255 // Run init
259256 run_cargo_rail ( & ws. path , & [ "rail" , "init" , "--non-interactive" ] ) ?;
260257
261- let config_content = std:: fs:: read_to_string ( & ws. path . join ( ".config/rail.toml" ) ) ?;
258+ let config_content = std:: fs:: read_to_string ( ws. path . join ( ".config/rail.toml" ) ) ?;
262259
263260 // Verify ALL config sections and fields are present (active or commented)
264261
0 commit comments