Skip to content

Commit

Permalink
Update tests for zero-typed sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
GilOliveira committed May 2, 2023
1 parent f41fa5a commit a804ede
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
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);
}

#[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()
Expand All @@ -30,7 +39,7 @@ fn dns_display () {

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

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

#[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()
Expand All @@ -60,20 +69,20 @@ async fn get_dns_records() {

#[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()
.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);
// }

0 comments on commit a804ede

Please sign in to comment.