-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathapi_users.rs
More file actions
77 lines (72 loc) · 1.75 KB
/
Copy pathapi_users.rs
File metadata and controls
77 lines (72 loc) · 1.75 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
mod common;
use common::get_api_user_ctx;
use twitter_v2::Result;
#[tokio::test]
async fn get_users_by() -> Result<()> {
let res = get_api_user_ctx()
.await
.get_users_by_usernames(&["TwitterDev", "Twitter"])
.send()
.await?;
assert_eq!(res.data().unwrap().len(), 2);
Ok(())
}
#[tokio::test]
async fn get_user_by_username() -> Result<()> {
let _ = get_api_user_ctx()
.await
.get_user_by_username("TwitterDev")
.send()
.await?;
Ok(())
}
#[tokio::test]
async fn get_users_me() -> Result<()> {
let _ = get_api_user_ctx().await.get_users_me().send().await?;
Ok(())
}
#[tokio::test]
async fn manage_user_following() -> Result<()> {
let twitter_dev_id = 2244994945;
let api = get_api_user_ctx().await;
let me = api.get_users_me().send().await?.into_data().unwrap();
assert!(!api
.get_user_following(me.id)
.send()
.await?
.into_data()
.unwrap()
.into_iter()
.any(|user| user.id == twitter_dev_id),);
assert!(
api.post_user_following(me.id, twitter_dev_id)
.await?
.into_data()
.unwrap()
.following
);
assert!(api
.get_user_following(me.id)
.send()
.await?
.into_data()
.unwrap()
.into_iter()
.any(|user| user.id == twitter_dev_id),);
assert!(
!api.delete_user_following(me.id, twitter_dev_id)
.await?
.into_data()
.unwrap()
.following
);
assert!(!api
.get_user_following(me.id)
.send()
.await?
.into_data()
.unwrap()
.into_iter()
.any(|user| user.id == twitter_dev_id),);
Ok(())
}