diff --git a/src/lib.rs b/src/lib.rs index af6eee9..3e61749 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,20 +158,26 @@ mod test { fn should_query_ssh_config() { let mut config = SshConfig::default(); // add config - let mut params1 = HostParams::default(); - params1.bind_address = Some(String::from("0.0.0.0")); + let mut params1 = HostParams { + bind_address: Some(String::from("0.0.0.0")), + ..Default::default() + }; config.hosts.push(Host::new( vec![HostClause::new(String::from("192.168.*.*"), false)], params1.clone(), )); - let mut params2 = HostParams::default(); - params2.bind_interface = Some(String::from("tun0")); + let params2 = HostParams { + bind_interface: Some(String::from("tun0")), + ..Default::default() + }; config.hosts.push(Host::new( vec![HostClause::new(String::from("192.168.10.*"), false)], params2.clone(), )); - let mut params3 = HostParams::default(); - params3.host_name = Some(String::from("172.26.104.4")); + let params3 = HostParams { + host_name: Some(String::from("172.26.104.4")), + ..Default::default() + }; config.hosts.push(Host::new( vec![ HostClause::new(String::from("172.26.*.*"), false), diff --git a/src/params.rs b/src/params.rs index 2d5e455..7c80a04 100644 --- a/src/params.rs +++ b/src/params.rs @@ -246,31 +246,31 @@ mod test { #[test] fn should_merge_params() { let mut params = HostParams::default(); - let mut b = HostParams::default(); - b.bind_address = Some(String::from("pippo")); - b.bind_interface = Some(String::from("tun0")); - b.ca_signature_algorithms = Some(vec![]); - b.certificate_file = Some(PathBuf::default()); - b.ciphers = Some(vec![]); - b.compression = Some(true); - b.connect_timeout = Some(Duration::from_secs(1)); - b.connection_attempts = Some(3); - b.host_key_algorithms = Some(vec![]); - b.host_name = Some(String::from("192.168.1.2")); - b.identity_file = Some(vec![PathBuf::default()]); - b.ignore_unknown = Some(vec![]); - b.kex_algorithms = Some(vec![]); - b.mac = Some(vec![]); - b.port = Some(22); - b.pubkey_accepted_algorithms = Some(vec![]); - b.pubkey_authentication = Some(true); - b.remote_forward = Some(32); - b.server_alive_interval = Some(Duration::from_secs(10)); - #[cfg(target_os = "macos")] - { - b.use_keychain = Some(true); - } - b.tcp_keep_alive = Some(true); + let mut b = HostParams { + bind_address: Some(String::from("pippo")), + bind_interface: Some(String::from("tun0")), + ca_signature_algorithms: Some(vec![]), + certificate_file: Some(PathBuf::default()), + ciphers: Some(vec![]), + compression: Some(true), + connect_timeout: Some(Duration::from_secs(1)), + connection_attempts: Some(3), + host_key_algorithms: Some(vec![]), + host_name: Some(String::from("192.168.1.2")), + identity_file: Some(vec![PathBuf::default()]), + ignore_unknown: Some(vec![]), + kex_algorithms: Some(vec![]), + mac: Some(vec![]), + port: Some(22), + pubkey_accepted_algorithms: Some(vec![]), + pubkey_authentication: Some(true), + remote_forward: Some(32), + server_alive_interval: Some(Duration::from_secs(10)), + #[cfg(target_os = "macos")] + use_keychain: Some(true), + tcp_keep_alive: Some(true), + ..Default::default() + }; params.merge(&b); assert!(params.bind_address.is_some()); assert!(params.bind_interface.is_some());