gscholar/
lib.rs

1pub mod scholar;
2
3#[cfg(test)]
4mod tests {
5    use crate::scholar;
6    #[test]
7    fn new_scholar_query() {
8        let sc = scholar::ScholarArgs{
9            query: "machine-learning",
10            cite_id: None,
11            from_year: None,
12            to_year: None,
13            sort_by: None,
14            cluster_id: None,
15            lang: None,
16            lang_limit: None,
17            limit: Some(3),
18            offset: Some(0),
19            adult_filtering: None,
20            include_similar_results: None,
21            include_citations: None,
22        };
23        assert_eq!(sc.query, "machine-learning");
24    }
25
26    #[tokio::test]
27    async fn scrape() {
28        let sc = scholar::ScholarArgs{
29            query: "machine-learning",
30            cite_id: None,
31            from_year: None,
32            to_year: None,
33            sort_by: None,
34            cluster_id: None,
35            lang: None,
36            lang_limit: None,
37            limit: Some(3),
38            offset: Some(0),
39            adult_filtering: None,
40            include_similar_results: None,
41            include_citations: None,
42        };
43
44        let client = scholar::init_client();
45        match client.scrape_scholar(&sc).await {
46            Ok(result) => assert_eq!(result.len(), 3),
47            Err(_e) => assert_eq!(true, false),
48        };
49    }
50}