boosty_rs/
lib.rs

1//! This crate provides asynchronous functions to access Boosty not documented, but accessible API
2
3/// API calls
4pub mod request;
5
6/// API authorization
7pub mod auth;
8
9/// API types
10pub mod types;
11
12/// Tests
13#[cfg(test)]
14mod tests {
15    use crate::request;
16
17    /// Test that post title is equal to hard-coded here and test is Boosty API still the same
18    #[tokio::test]
19    async fn fetch_post_test() -> Result<(), Box<dyn std::error::Error>> {
20        let response = request::fetch_post("crptmem".to_string(), "64c7b376-5825-42ae-90d1-8c28fac5f6ab".to_string(), None).await?;
21        assert_eq!(response.title, "boosty-rs unit test fetch_post");
22        Ok(())
23    }
24
25    /// Test that another post title is equal to hard-coded here and test is Boosty API still the same
26    #[tokio::test]
27    async fn fetch_post_second_test() -> Result<(), Box<dyn std::error::Error>> {
28        let response = request::fetch_post("boosty".to_string(), "8c2ba2c5-da5c-4a64-94c4-4fef6147333a".to_string(), None).await?;
29        assert_eq!(response.title, "Boosty.to VS Patreon");
30        Ok(())
31    }
32
33    /// Test all posts
34    #[tokio::test]
35    async fn fetch_posts() -> Result<(), Box<dyn std::error::Error>> {
36        let response = request::fetch_posts("crptmem".to_string(), 128, None).await?;
37        println!("{:#?}", response); 
38        Ok(())
39    }
40}