Skip to main content

itchio_api/
wharf.rs

1use serde::Deserialize;
2
3use crate::{Itchio, ItchioError};
4
5#[derive(Clone, Debug, Deserialize)] #[allow(dead_code)]
6pub struct WharfStatus {
7  success: bool
8}
9
10impl Itchio {
11  /// Request the status of the wharf infrastructure.
12  pub async fn get_wharf_status(&self) -> Result<WharfStatus, ItchioError> {
13    Ok(self.request::<WharfStatus>("wharf/status".to_string()).await?)
14  }
15}
16
17#[cfg(test)]
18mod tests {
19  use super::*;
20  use std::env;
21  use dotenv::dotenv;
22
23  #[tokio::test]
24  async fn good() {
25    dotenv().ok();
26    let client_secret = env::var("KEY").expect("KEY has to be set");
27    let api = Itchio::new(client_secret);
28    let wharf = api.get_wharf_status().await.inspect_err(|err| eprintln!("Error spotted: {}", err));
29    assert!(wharf.is_ok())
30  }
31
32  #[tokio::test]
33  async fn bad_key() {
34    let api = Itchio::new("bad_key".to_string());
35    let wharf = api.get_wharf_status().await;
36    assert!(wharf.is_err_and(|err| matches!(err, ItchioError::BadKey)))
37  }
38}