fix team deserialisation

This commit is contained in:
TotallyNot 2022-09-10 14:16:56 +02:00
parent f923942164
commit d888530d24
2 changed files with 5 additions and 30 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "torn-api"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
authors = ["Pyrit [2111649]"]
license = "MIT"

View file

@ -215,12 +215,13 @@ where
D: Deserializer<'de>,
{
#[derive(Deserialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "camelCase")]
enum Field {
Name,
Score,
Team,
Attacks,
TeamName,
}
#[derive(Deserialize)]
@ -295,6 +296,7 @@ where
})
}
}
_ => (),
}
}
@ -413,6 +415,7 @@ mod tests {
response.discord().unwrap();
response.profile().unwrap();
response.personal_stats().unwrap();
response.crimes().unwrap();
}
#[async_test]
@ -443,32 +446,4 @@ mod tests {
let profile = response.profile().unwrap();
assert!(profile.competition.is_some());
}
#[async_test]
async fn team_invisible() {
let key = setup();
let response = Client::default()
.torn_api(key)
.user(|b| b.id(2526617).selections(&[Selection::Profile]))
.await
.unwrap();
let profile = response.profile().unwrap();
assert!(profile.competition.is_none());
}
#[async_test]
async fn team_none() {
let key = setup();
let response = Client::default()
.torn_api(key)
.user(|b| b.id(2681712).selections(&[Selection::Profile]))
.await
.unwrap();
let profile = response.profile().unwrap();
assert!(profile.competition.is_none());
}
}