diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-01-10 11:28:55 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-01-10 13:01:39 +0100 |
| commit | bce4e343f28101866af0bbba42dc3bbf6d64d1f7 (patch) | |
| tree | 0e57e67097cdeee911252d5eb6aae51d779566c9 | |
| parent | df4d821fb48fb547c3448246adab9b4b3b37f5f8 (diff) | |
| download | mullvadvpn-bce4e343f28101866af0bbba42dc3bbf6d64d1f7.tar.xz mullvadvpn-bce4e343f28101866af0bbba42dc3bbf6d64d1f7.zip | |
Rename OpenVpnBuilder -> OpenVpnCommand
| -rw-r--r-- | src/process/mod.rs | 28 | ||||
| -rw-r--r-- | tests/process.rs | 6 |
2 files changed, 17 insertions, 17 deletions
diff --git a/src/process/mod.rs b/src/process/mod.rs index aa298ce465..0538eb8c62 100644 --- a/src/process/mod.rs +++ b/src/process/mod.rs @@ -15,17 +15,17 @@ use self::monitor::{MonitoredChild, ChildSpawner}; /// An OpenVPN process builder, providing control over the different arguments that the OpenVPN /// binary accepts. -pub struct OpenVpnBuilder { +pub struct OpenVpnCommand { openvpn_bin: OsString, config: Option<PathBuf>, remotes: Vec<RemoteAddr>, } -impl OpenVpnBuilder { - /// Constructs a new `OpenVpnBuilder` for launching OpenVPN processes from the binary at +impl OpenVpnCommand { + /// Constructs a new `OpenVpnCommand` for launching OpenVPN processes from the binary at /// `openvpn_bin`. pub fn new<P: AsRef<OsStr>>(openvpn_bin: P) -> Self { - OpenVpnBuilder { + OpenVpnCommand { openvpn_bin: OsString::from(openvpn_bin.as_ref()), config: None, remotes: vec![], @@ -77,8 +77,8 @@ impl OpenVpnBuilder { } } -impl fmt::Display for OpenVpnBuilder { - /// Format the program and arguments of an `OpenVpnBuilder` for display. Any non-utf8 data is +impl fmt::Display for OpenVpnCommand { + /// Format the program and arguments of an `OpenVpnCommand` for display. Any non-utf8 data is /// lossily converted using the utf8 replacement character. fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.write_str(&self.openvpn_bin.to_string_lossy())?; @@ -121,9 +121,9 @@ impl MonitoredChild for ClonableChild { } } -impl ChildSpawner<ClonableChild> for OpenVpnBuilder { +impl ChildSpawner<ClonableChild> for OpenVpnCommand { fn spawn(&mut self) -> io::Result<ClonableChild> { - OpenVpnBuilder::spawn(self).map(|child| child.into_clonable()) + OpenVpnCommand::spawn(self).map(|child| child.into_clonable()) } } @@ -132,11 +132,11 @@ impl ChildSpawner<ClonableChild> for OpenVpnBuilder { mod tests { use net::RemoteAddr; use std::ffi::OsString; - use super::OpenVpnBuilder; + use super::OpenVpnCommand; #[test] fn no_arguments() { - let testee_args = OpenVpnBuilder::new("").get_arguments(); + let testee_args = OpenVpnCommand::new("").get_arguments(); assert_eq!(0, testee_args.len()); } @@ -144,7 +144,7 @@ mod tests { fn passes_one_remote() { let remote = RemoteAddr::new("example.com", 3333); - let testee_args = OpenVpnBuilder::new("").remotes(remote).unwrap().get_arguments(); + let testee_args = OpenVpnCommand::new("").remotes(remote).unwrap().get_arguments(); assert!(testee_args.contains(&OsString::from("example.com"))); assert!(testee_args.contains(&OsString::from("3333"))); @@ -154,7 +154,7 @@ mod tests { fn passes_two_remotes() { let remotes = vec![RemoteAddr::new("127.0.0.1", 998), RemoteAddr::new("fe80::1", 1337)]; - let testee_args = OpenVpnBuilder::new("").remotes(&remotes[..]).unwrap().get_arguments(); + let testee_args = OpenVpnCommand::new("").remotes(&remotes[..]).unwrap().get_arguments(); assert!(testee_args.contains(&OsString::from("127.0.0.1"))); assert!(testee_args.contains(&OsString::from("998"))); @@ -164,14 +164,14 @@ mod tests { #[test] fn accepts_str() { - assert!(OpenVpnBuilder::new("").remotes("10.0.0.1:1377").is_ok()); + assert!(OpenVpnCommand::new("").remotes("10.0.0.1:1377").is_ok()); } #[test] fn accepts_slice_of_str() { let remotes = ["10.0.0.1:1337", "127.0.0.1:99"]; - let testee_args = OpenVpnBuilder::new("").remotes(&remotes[..]).unwrap().get_arguments(); + let testee_args = OpenVpnCommand::new("").remotes(&remotes[..]).unwrap().get_arguments(); assert!(testee_args.contains(&OsString::from("10.0.0.1"))); assert!(testee_args.contains(&OsString::from("1337"))); diff --git a/tests/process.rs b/tests/process.rs index 2281a9d990..149cb8e612 100644 --- a/tests/process.rs +++ b/tests/process.rs @@ -2,7 +2,7 @@ extern crate talpid_core; mod util; -use talpid_core::process::OpenVpnBuilder; +use talpid_core::process::OpenVpnCommand; #[cfg(target_os = "linux")] #[test] @@ -17,7 +17,7 @@ fn check_test_environment() { #[cfg(target_os = "linux")] #[test] fn openvpn_builder_starts_correct_process() { - let mut child = OpenVpnBuilder::new("echo").spawn().unwrap(); + let mut child = OpenVpnCommand::new("echo").spawn().unwrap(); let args = util::read_args_for_proc(child.id()); assert_eq!(vec!["echo"], args); @@ -28,7 +28,7 @@ fn openvpn_builder_starts_correct_process() { #[test] fn openvpn_builder_passes_config() { let config_path = "/path/to/config".to_owned(); - let mut child = OpenVpnBuilder::new("echo").config(&config_path).spawn().unwrap(); + let mut child = OpenVpnCommand::new("echo").config(&config_path).spawn().unwrap(); let args = util::read_args_for_proc(child.id()); assert!(args.contains(&config_path)); |
