-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98ced36
commit 915a549
Showing
2 changed files
with
122 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use omglol::{OmglolClient, structures::{DNStype, RequestError}}; | ||
|
||
use dotenv::dotenv; | ||
use std::env; | ||
|
||
fn init_client() -> (OmglolClient, 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)); | ||
println!("Using account {} for testing", &address); | ||
|
||
return (client, address); | ||
} | ||
|
||
#[tokio::test] | ||
async fn get_all_statuses() { | ||
let (client, address) = init_client(); | ||
let response = client.get_all_statuses(&address) | ||
.await | ||
.unwrap() | ||
.response; | ||
println!("{:#?}", response); | ||
} | ||
|
||
#[test] | ||
fn dns_display () { | ||
assert!(format!("{}", DNStype::A) == "A"); | ||
} | ||
|
||
#[tokio::test] | ||
async fn get_service_status() { | ||
let (client, _) = init_client(); | ||
let service_status = client.service_status() | ||
.await | ||
.unwrap() | ||
.response; | ||
println!("{:#?}", service_status); | ||
} | ||
|
||
#[tokio::test] | ||
async fn get_profile_themes() { | ||
let (client, _) = init_client(); | ||
let info = client.get_profile_themes() | ||
.await | ||
.unwrap() | ||
.response; | ||
println!("{:#?}", info); | ||
} | ||
|
||
#[tokio::test] | ||
async fn get_dns_records() { | ||
let (client, address) = init_client(); | ||
let response = client.get_dns_records(&address) | ||
.await | ||
.unwrap() | ||
.response; | ||
println!("{:#?}", response); | ||
} | ||
|
||
#[tokio::test] | ||
async fn get_web_page() { | ||
let (client, address) = init_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); | ||
} |