diff --git a/crates/tailscale-api/src/lib.rs b/crates/tailscale-api/src/lib.rs index c57f851..c30f858 100644 --- a/crates/tailscale-api/src/lib.rs +++ b/crates/tailscale-api/src/lib.rs @@ -1,5 +1,6 @@ use chrono::prelude::*; use serde::{Deserialize, Serialize}; +use std::env::VarError; #[derive(thiserror::Error, Debug)] pub enum Error { @@ -8,6 +9,9 @@ pub enum Error { #[error("http error: {0}")] Reqwest(#[from] reqwest::Error), + + #[error("no such envvar: {0}")] + NoSuchEnvvar(#[from] VarError), } pub type Result = std::result::Result; @@ -147,8 +151,32 @@ pub struct Device { #[cfg(test)] mod tests { + use super::*; + use std::env::var as envvar; + + fn client() -> Result { + Client::new( + envvar("TAILSCALE_TAILNET")?, + envvar("TAILSCALE_API_KEY")?, + "tailscale_api::test".into(), + ) + } + #[tokio::test] - async fn it_works() { - assert_eq!(2 + 2, 4); + async fn basic_tests() { + async fn inner() -> Result { + let cli = client()?; + + cli.devices().await?; + cli.get_nameservers().await?; + //cli.set_nameservers(ns).await?; + cli.get_acl().await?; + + Ok(()) + } + + if let Err(why) = inner().await { + println!("error running tests: {}", why) + } } }