all repos — omglolrs @ a804edec9b696040ccf81cbce7ad871f8002e4d2

A Rust wrapper for api.omg.lol.

Update tests for zero-typed sizes
Gil Poiares-Oliveira gil@poiares-oliveira.com
Tue, 02 May 2023 19:35:44 +0100
commit

a804edec9b696040ccf81cbce7ad871f8002e4d2

parent

f41fa5a88bc5b170701e4e7b51f8f4294b774e08

1 files changed, 26 insertions(+), 17 deletions(-)

jump to
M tests/integration_tests.rstests/integration_tests.rs

@@ -1,13 +1,22 @@

-use omglol::{OmglolClient, structures::{DNStype, RequestError}}; +use omglol::{OmglolClient, structures::{DNStype, RequestError}, client::{Auth, NoAuth}}; use dotenv::dotenv; use std::env; -fn init_client() -> (OmglolClient, String) { +fn init_noauth_client() -> (OmglolClient<NoAuth>, String) { + dotenv().ok(); + let address = env::var("OMGLOL_ADDRESS").unwrap_or("foobar".to_string()); + let client_noauth = OmglolClient::new(); + println!("Using account {} for testing", &address); + + return (client_noauth, address); +} + +fn init_auth_client() -> (OmglolClient<Auth>, String) { dotenv().ok(); let address = env::var("OMGLOL_ADDRESS").unwrap_or("foobar".to_string()); let api_key = env::var("OMGLOL_API_KEY").unwrap_or("".to_string()); - let client = OmglolClient::new(Some(api_key)); + let client = OmglolClient::new().auth(api_key); println!("Using account {} for testing", &address); return (client, address);

@@ -15,7 +24,7 @@ }

#[tokio::test] async fn get_all_statuses() { - let (client, address) = init_client(); + let (client, address) = init_noauth_client(); let response = client.get_all_statuses(&address) .await .unwrap()

@@ -30,7 +39,7 @@ }

#[tokio::test] async fn get_service_status() { - let (client, _) = init_client(); + let (client, _) = init_noauth_client(); let service_status = client.service_status() .await .unwrap()

@@ -40,7 +49,7 @@ }

#[tokio::test] async fn get_profile_themes() { - let (client, _) = init_client(); + let (client, _) = init_noauth_client(); let info = client.get_profile_themes() .await .unwrap()

@@ -50,7 +59,7 @@ }

#[tokio::test] async fn get_dns_records() { - let (client, address) = init_client(); + let (client, address) = init_auth_client(); let response = client.get_dns_records(&address) .await .unwrap()

@@ -60,7 +69,7 @@ }

#[tokio::test] async fn get_web_page() { - let (client, address) = init_client(); + let (client, address) = init_auth_client(); let response = client.get_web_page(&address) .await .unwrap()

@@ -68,12 +77,12 @@ .response;

println!("{:#?}", response); } -#[tokio::test] -async fn query_unauthorized_endpoint() { - let (client, _) = init_client(); - let response_result = client.get_web_page("foobar") - .await; - let raised_error = *&dyn response_result.err().unwrap(); - assert_eq!(*raised_error.status_code, 401); - println!("{:#?}", response_result); -} +// #[tokio::test] +// async fn query_unauthorized_endpoint() { +// let (client, _) = init_auth_client(); +// let response_result = client.get_web_page("foobar") +// .await; +// let raised_error = *&dyn response_result.err().unwrap(); +// assert_eq!(*raised_error.status_code, 401); +// println!("{:#?}", response_result); +// }