2 Commits

Author SHA1 Message Date
Lukas Wölfer
22fa677d8a Wrapped test 2025-08-12 21:43:06 +02:00
Lukas Wölfer
2faf8038fe Minor testing 2025-08-12 21:21:47 +02:00
3 changed files with 34 additions and 4 deletions

1
emeline.json Normal file

File diff suppressed because one or more lines are too long

View File

@@ -51,6 +51,8 @@ pub struct CompState {
pub rank: DanceRank,
pub points: u16,
}
#[derive(Debug)]
pub struct DanceInfo {
pub firstname: String,
pub lastname: String,

View File

@@ -11,12 +11,15 @@ pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
.map_err(DanceInfoError::ClientBuild)?;
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());
let request = client
.request(
reqwest::Method::POST,
"https://points.worldsdc.com/lookup2020/find",
)
.request(reqwest::Method::POST, url)
.form(&params)
.build()
.map_err(DanceInfoError::RequestBuild)?;
@@ -29,6 +32,30 @@ pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
Ok(x.into())
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used, reason="Allow unwrap in tests")]
use crate::worldsdc::fetch_wsdc_info;
#[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);
x.unwrap();
}
}
#[derive(thiserror::Error, Debug)]
pub enum DanceInfoError {
#[error("Failed to build client: {0}")]