add upload listing and demo not found

This commit is contained in:
Robin Appelman 2020-12-09 23:40:46 +01:00
commit 9c15fdcf82
3 changed files with 40 additions and 3 deletions

4
Cargo.lock generated
View file

@ -337,9 +337,9 @@ dependencies = [
[[package]] [[package]]
name = "demostf-client" name = "demostf-client"
version = "0.1.4" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a93173a049ea144a947ebbaf115bce8a95f57396b9f5ffa7449d1b2e9da46607" checksum = "63004130b42c097bd2b5f30ec219a3a96c13d8ba142d3ea60e96c391cb84875e"
dependencies = [ dependencies = [
"chrono", "chrono",
"hex", "hex",

View file

@ -5,7 +5,7 @@ authors = ["Robin Appelman <robin@icewind.nl>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
demostf-client = { version = "0.1.4", default-features = false, features = ["rustls-tls"] } demostf-client = { version = "0.1.5", default-features = false, features = ["rustls-tls"] }
sqlx = { version = "0.4", features = ["postgres", "runtime-tokio-rustls"] } sqlx = { version = "0.4", features = ["postgres", "runtime-tokio-rustls"] }
dotenv = "0.15.0" dotenv = "0.15.0"
color-eyre = "0.5.8" color-eyre = "0.5.8"

View file

@ -111,6 +111,20 @@ async fn main() -> Result<()> {
}) })
.await?; .await?;
test.step("not found", |client| async move {
let result = client.get(10).await;
match result {
Ok(_) => Err(Report::msg("Expected error during upload")),
Err(demostf_client::Error::DemoNotFound(10)) => Ok(()),
Err(e) => Err(Report::msg(format!(
"Unexpected error during set url: {}",
e
))),
}
})
.await?;
test.step("list demos", |client| async move { test.step("list demos", |client| async move {
let list = client.list(ListParams::default(), 1).await?; let list = client.list(ListParams::default(), 1).await?;
assert_eq(list.len(), 1)?; assert_eq(list.len(), 1)?;
@ -331,6 +345,29 @@ async fn main() -> Result<()> {
}) })
.await?; .await?;
test.step("list by uploader", |client| async move {
let list = client
.list_uploads(
SteamID::from(76561197992327511),
ListParams::default().with_order(ListOrder::Ascending),
1,
)
.await?;
assert_eq(list.len(), 0)?;
let list = client
.list_uploads(
SteamID::from(76561198024494988),
ListParams::default().with_order(ListOrder::Ascending),
1,
)
.await?;
assert_eq(list.len(), 5)?;
assert_eq(list[0].id, 1)?;
Ok(())
})
.await?;
Ok(()) Ok(())
}) })
.await; .await;