Skip to main content

itchio_api/
wharf.rs

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