mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-10 00:20:29 -04:00
wifi: Add Wifi backend tests
This commit is contained in:
parent
05031b3ee1
commit
85f68b4c54
1 changed files with 44 additions and 0 deletions
44
src/wifi.rs
44
src/wifi.rs
|
@ -249,3 +249,47 @@ pub async fn set_wifi_backend(backend: WifiBackend) -> Result<()> {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::testing;
|
||||||
|
use tokio::fs::{create_dir_all, write};
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_wifi_backend_to_string() {
|
||||||
|
assert_eq!(WifiBackend::IWD.to_string(), "iwd");
|
||||||
|
assert_eq!(WifiBackend::WPASupplicant.to_string(), "wpa_supplicant");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_get_wifi_backend() {
|
||||||
|
let h = testing::start();
|
||||||
|
|
||||||
|
create_dir_all(path(WIFI_BACKEND_PATH).parent().unwrap())
|
||||||
|
.await
|
||||||
|
.expect("create_dir_all");
|
||||||
|
|
||||||
|
assert!(get_wifi_backend().await.is_err());
|
||||||
|
|
||||||
|
write(path(WIFI_BACKEND_PATH), "[device]")
|
||||||
|
.await
|
||||||
|
.expect("write");
|
||||||
|
assert!(get_wifi_backend().await.is_err());
|
||||||
|
|
||||||
|
write(path(WIFI_BACKEND_PATH), "[device]\nwifi.backend=fake\n")
|
||||||
|
.await
|
||||||
|
.expect("write");
|
||||||
|
assert!(get_wifi_backend().await.is_err());
|
||||||
|
|
||||||
|
write(path(WIFI_BACKEND_PATH), "[device]\nwifi.backend=iwd\n")
|
||||||
|
.await
|
||||||
|
.expect("write");
|
||||||
|
assert_eq!(get_wifi_backend().await.unwrap(), WifiBackend::IWD);
|
||||||
|
|
||||||
|
write(path(WIFI_BACKEND_PATH), "[device]\nwifi.backend=wpa_supplicant\n")
|
||||||
|
.await
|
||||||
|
.expect("write");
|
||||||
|
assert_eq!(get_wifi_backend().await.unwrap(), WifiBackend::WPASupplicant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue