Add test for get_thread() function
This commit is contained in:
parent
6945ded963
commit
9fd6724819
1 changed files with 29 additions and 0 deletions
|
@ -1608,6 +1608,35 @@ mod tests {
|
||||||
assert_eq!(timeline.iter().any(|post| post.id == repost.id), true);
|
assert_eq!(timeline.iter().any(|post| post.id == repost.id), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
|
async fn test_get_thread() {
|
||||||
|
let db_client = &mut create_test_database().await;
|
||||||
|
let user_data = UserCreateData {
|
||||||
|
username: "test".to_string(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let user = create_user(db_client, user_data).await.unwrap();
|
||||||
|
let post_data_1 = PostCreateData {
|
||||||
|
content: "my post".to_string(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let post_1 = create_post(db_client, &user.id, post_data_1).await.unwrap();
|
||||||
|
let post_data_2 = PostCreateData {
|
||||||
|
content: "my reply".to_string(),
|
||||||
|
in_reply_to_id: Some(post_1.id.clone()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let post_2 = create_post(db_client, &user.id, post_data_2).await.unwrap();
|
||||||
|
let thread = get_thread(
|
||||||
|
db_client,
|
||||||
|
&post_2.id,
|
||||||
|
Some(&user.id),
|
||||||
|
).await.unwrap();
|
||||||
|
assert_eq!(thread[0].id, post_1.id);
|
||||||
|
assert_eq!(thread[1].id, post_2.id);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_find_extraneous_posts() {
|
async fn test_find_extraneous_posts() {
|
||||||
|
|
Loading…
Reference in a new issue