use n0_watcher::Watcher;
use netwatch::netmon;
use testresult::TestResult;
#[cfg(not(wasm_browser))]
use tokio::test;
#[cfg(wasm_browser)]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
async fn smoke_test() -> TestResult {
setup_logging();
tracing::info!("Creating netmon::Monitor");
let monitor = netmon::Monitor::new().await?;
tracing::info!("netmon::Monitor created.");
tracing::info!("subscribing to netmon");
let mut sub = monitor.interface_state();
let current = sub.get();
tracing::info!(?current, "network change");
tracing::info!("successfully subscribed to netmon");
tracing::info!("dropping netmon::Monitor");
drop(monitor);
tracing::info!("dropped.");
Ok(())
}
#[cfg(wasm_browser)]
fn setup_logging() {
let mut config = wasm_tracing::WasmLayerConfig::new();
config.set_max_level(tracing::Level::TRACE);
wasm_tracing::set_as_global_default_with_config(config).unwrap();
}
#[cfg(not(wasm_browser))]
fn setup_logging() {
tracing_subscriber::fmt().init();
}