Minor testing

This commit is contained in:
Lukas Wölfer
2025-08-12 21:21:47 +02:00
parent 33180e95a3
commit 2faf8038fe
3 changed files with 27 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,23 @@ pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
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)]
pub enum DanceInfoError {
#[error("Failed to build client: {0}")]