1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#[cfg(test)]
mod tests {
    use lazy_static::lazy_static;
    use reqwest::{Client, ClientBuilder};

    use crate::reddit::{connection::RedditConnection, request::RedditRequest};

    lazy_static! {
        static ref HTTP: Client = ClientBuilder::new().user_agent("RMoods").build().unwrap();
    }
    static INIT: std::sync::Once = std::sync::Once::new();

    fn init() {
        INIT.call_once(|| {
            let _ = dotenvy::dotenv();
        })
    }

    #[tokio::test]
    async fn test_app_can_fetch_access_token() {
        init();
        let conn = RedditConnection::new(HTTP.clone()).await.unwrap();
        let _ = conn.client.fetch_access_token(&conn.http).await;
    }
}