1use crate::{models::Hotspot, *};
2
3pub fn all(client: &Client) -> Stream<Hotspot> {
5 client.fetch_stream("/hotspots", NO_QUERY)
6}
7
8pub async fn get(client: &Client, address: &str) -> Result<Hotspot> {
10 client
11 .fetch(&format!("/hotspots/{}", address), NO_QUERY)
12 .await
13}
14
15#[cfg(test)]
16mod test {
17 use super::*;
18 use tokio::test;
19
20 #[test]
21 async fn all() {
22 let client = get_test_client();
23 let hotspots = hotspots::all(&client)
24 .take(10)
25 .into_vec()
26 .await
27 .expect("hotspots");
28 assert_eq!(hotspots.len(), 10);
29 }
30
31 #[test]
32 async fn get() {
33 let client = get_test_client();
34 let hotspot = hotspots::get(
35 &client,
36 "112vvSrNAwJRSmR54aqFLEhbr6cy6T4Ufuja4VWVrxvkUAUxL2yG",
37 )
38 .await
39 .expect("hotspot");
40 assert_eq!(
41 hotspot.address,
42 "112vvSrNAwJRSmR54aqFLEhbr6cy6T4Ufuja4VWVrxvkUAUxL2yG"
43 );
44 }
45}