Add test for Like::build_undo

This commit is contained in:
Kitaiti Makoto 2022-01-09 01:55:06 +09:00
parent 9ab9d29efb
commit e2077bed59

View File

@ -205,4 +205,28 @@ mod tests {
Ok(()) Ok(())
}); });
} }
#[test]
fn build_undo() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (posts, _users, _blogs) = fill_database(&conn);
let post = &posts[0];
let user = &post.get_authors(&conn)?[0];
let like = Like::insert(&*conn, NewLike::new(post, user))?;
let act = like.build_undo(&*conn)?;
let expected = json!({
"actor": "https://plu.me/@/admin/",
"cc": ["https://plu.me/@/admin/followers"],
"id": "https://plu.me/@/admin/like/https://plu.me/~/BlogName/testing#delete",
"object": "https://plu.me/@/admin/like/https://plu.me/~/BlogName/testing#delete",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"type": "Undo",
});
assert_json_eq!(to_value(act)?, expected);
Ok(())
});
}
} }