Skip to content

Commit

Permalink
feat: added app_ids function
Browse files Browse the repository at this point in the history
  • Loading branch information
cecilia-sanare committed Mar 13, 2024
1 parent 6d416d5 commit 3e0d33a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ impl Protontweaks {
self.try_apps().await.unwrap()
}

pub async fn try_app_ids(&self) -> Result<Vec<String>, String> {
self.try_apps()
.await
.map(|apps| apps.iter().map(|app| app.id.clone()).collect())
}

pub async fn app_ids(&self) -> Vec<String> {
self.try_app_ids().await.unwrap()
}

pub async fn try_app(&self, app_id: &str) -> Result<App, String> {
self.get::<App>(&format!("{app_id}.json")).await
}
Expand Down Expand Up @@ -127,6 +137,17 @@ mod tests {
assert!(api.apps().await.len() > 0, "Should be a list of apps");
}

#[tokio::test]
async fn app_ids() {
let api = Protontweaks::new();

assert!(
api.try_app_ids().await.unwrap().len() > 0,
"Should be a list of app ids"
);
assert!(api.app_ids().await.len() > 0, "Should be a list of app ids");
}

#[tokio::test]
async fn try_app() {
let expected_id = "644930";
Expand Down

0 comments on commit 3e0d33a

Please sign in to comment.