Extract comments::tests::prepare_activity()
This commit is contained in:
parent
4842385ca6
commit
65372d2018
@ -402,6 +402,7 @@ impl CommentTree {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::blogs::Blog;
|
||||||
use crate::inbox::{inbox, tests::fill_database, InboxResult};
|
use crate::inbox::{inbox, tests::fill_database, InboxResult};
|
||||||
use crate::safe_string::SafeString;
|
use crate::safe_string::SafeString;
|
||||||
use crate::tests::{db, format_datetime};
|
use crate::tests::{db, format_datetime};
|
||||||
@ -409,15 +410,10 @@ mod tests {
|
|||||||
use diesel::Connection;
|
use diesel::Connection;
|
||||||
use serde_json::{json, to_value};
|
use serde_json::{json, to_value};
|
||||||
|
|
||||||
// creates a post, get it's Create activity, delete the post,
|
fn prepare_activity(conn: &DbConn) -> (Comment, Vec<Post>, Vec<User>, Vec<Blog>) {
|
||||||
// "send" the Create to the inbox, and check it works
|
let (posts, users, blogs) = fill_database(&conn);
|
||||||
#[test]
|
|
||||||
fn self_federation() {
|
|
||||||
let conn = &db();
|
|
||||||
conn.test_transaction::<_, (), _>(|| {
|
|
||||||
let (posts, users, _) = fill_database(&conn);
|
|
||||||
|
|
||||||
let original_comm = Comment::insert(
|
let comment = Comment::insert(
|
||||||
conn,
|
conn,
|
||||||
NewComment {
|
NewComment {
|
||||||
content: SafeString::new("My comment, mentioning to @user"),
|
content: SafeString::new("My comment, mentioning to @user"),
|
||||||
@ -431,6 +427,17 @@ mod tests {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
(comment, posts, users, blogs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// creates a post, get it's Create activity, delete the post,
|
||||||
|
// "send" the Create to the inbox, and check it works
|
||||||
|
#[test]
|
||||||
|
fn self_federation() {
|
||||||
|
let conn = &db();
|
||||||
|
conn.test_transaction::<_, (), _>(|| {
|
||||||
|
let (original_comm, posts, users, _blogs) = prepare_activity(&conn);
|
||||||
let act = original_comm.create_activity(&conn).unwrap();
|
let act = original_comm.create_activity(&conn).unwrap();
|
||||||
|
|
||||||
assert_json_eq!(to_value(&act).unwrap(), json!({
|
assert_json_eq!(to_value(&act).unwrap(), json!({
|
||||||
|
Loading…
Reference in New Issue
Block a user