test(rust/client): add unit test for DNS and network change notifiers (#6635)

Part of a yak shave towards removing Tauri.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
This commit is contained in:
Reactor Scram
2024-09-12 10:59:13 -05:00
committed by GitHub
parent 94cef31d52
commit ece8f7a5b7

View File

@@ -10,3 +10,30 @@ mod imp;
#[cfg(any(target_os = "windows", target_os = "linux"))]
pub use imp::{new_dns_notifier, new_network_notifier};
#[cfg(test)]
mod tests {
use super::*;
use crate::platform::DnsControlMethod;
/// Smoke test for the DNS and network change notifiers
///
/// Turn them on, wait a second, turn them off.
/// This tests that the threads quit gracefully when we call `close`, and they don't crash on startup.
#[tokio::test]
async fn notifiers() {
let tokio_handle = tokio::runtime::Handle::current();
let mut dns = new_dns_notifier(tokio_handle.clone(), DnsControlMethod::default())
.await
.unwrap();
let mut net = new_network_notifier(tokio_handle, DnsControlMethod::default())
.await
.unwrap();
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
dns.close().unwrap();
net.close().unwrap();
}
}