Chore(Test): Update Test Example

This commit is contained in:
Tochukwu Nkemdilim
2018-07-02 23:01:57 +01:00
parent c46bf7f494
commit 96c16e70a9
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -28,6 +28,15 @@ fn main() -> Result<(), io::Error> {
.takes_value(true) .takes_value(true)
.help("Password of the wireless network."), .help("Password of the wireless network."),
) )
.arg(
Arg::with_name("interface")
.short("i")
.long("interface")
.multiple(false)
.default_value("wlan0")
.takes_value(true)
.help("Wireless interface to connect through."),
)
.get_matches(); .get_matches();
// Get Password // Get Password
@@ -36,6 +45,9 @@ fn main() -> Result<(), io::Error> {
// Get SSID // Get SSID
let ssid = matches.value_of("ssid").unwrap(); let ssid = matches.value_of("ssid").unwrap();
// Get Wireless Interface
let ssid = matches.value_of("ssid").unwrap();
let wifi = WiFi::new(ssid)?; let wifi = WiFi::new(ssid)?;
println!("Connection Status: {}", wifi.connect(password)); println!("Connection Status: {}", wifi.connect(password));
+1 -1
View File
@@ -10,7 +10,7 @@ mod tests {
#[test] #[test]
fn connect_to_wifi_failed() { fn connect_to_wifi_failed() {
let config = Some(Config { let config = Some(Config {
interface: Some(String::from("wlo1")), interface: Some("wlo1"),
}); });
let wifi = WiFi::new("hello", config).unwrap(); let wifi = WiFi::new("hello", config).unwrap();