Minor testing
This commit is contained in:
1
emeline.json
Normal file
1
emeline.json
Normal file
File diff suppressed because one or more lines are too long
@@ -51,6 +51,8 @@ pub struct CompState {
|
|||||||
pub rank: DanceRank,
|
pub rank: DanceRank,
|
||||||
pub points: u16,
|
pub points: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct DanceInfo {
|
pub struct DanceInfo {
|
||||||
pub firstname: String,
|
pub firstname: String,
|
||||||
pub lastname: String,
|
pub lastname: String,
|
||||||
|
|||||||
@@ -11,12 +11,15 @@ pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
|||||||
.map_err(DanceInfoError::ClientBuild)?;
|
.map_err(DanceInfoError::ClientBuild)?;
|
||||||
|
|
||||||
let mut params = HashMap::new();
|
let mut params = HashMap::new();
|
||||||
|
|
||||||
|
let url = if cfg!(test) {
|
||||||
|
"https://o5grQU3Y.free.beeceptor.com/lookup2020/find"
|
||||||
|
} else {
|
||||||
|
"https://points.worldsdc.com/lookup2020/find"
|
||||||
|
};
|
||||||
params.insert("num", id.to_string());
|
params.insert("num", id.to_string());
|
||||||
let request = client
|
let request = client
|
||||||
.request(
|
.request(reqwest::Method::POST, url)
|
||||||
reqwest::Method::POST,
|
|
||||||
"https://points.worldsdc.com/lookup2020/find",
|
|
||||||
)
|
|
||||||
.form(¶ms)
|
.form(¶ms)
|
||||||
.build()
|
.build()
|
||||||
.map_err(DanceInfoError::RequestBuild)?;
|
.map_err(DanceInfoError::RequestBuild)?;
|
||||||
@@ -29,6 +32,23 @@ pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
|||||||
Ok(x.into())
|
Ok(x.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore = "Only run when the mock api is setup"]
|
||||||
|
fn test_fetch_wsdc() {
|
||||||
|
let rt = match tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
{
|
||||||
|
Ok(o) => o,
|
||||||
|
Err(e) => {
|
||||||
|
tracing::error!("Could not start runtime: {e}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let x = rt.block_on(fetch_wsdc_info(7));
|
||||||
|
dbg!(x);
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum DanceInfoError {
|
pub enum DanceInfoError {
|
||||||
#[error("Failed to build client: {0}")]
|
#[error("Failed to build client: {0}")]
|
||||||
|
|||||||
Reference in New Issue
Block a user