mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user