Make tests follow API changes

This commit is contained in:
Kitaiti Makoto
2021-01-30 23:15:07 +09:00
parent 25e52788c5
commit 78be49d57d
8 changed files with 305 additions and 338 deletions
+9 -10
View File
@@ -880,19 +880,18 @@ mod tests {
use super::*;
use crate::inbox::{inbox, tests::fill_database, InboxResult};
use crate::safe_string::SafeString;
use crate::tests::rockets;
use crate::tests::db;
use diesel::Connection;
// 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 r = rockets();
let conn = &*r.conn;
let conn = &db();
conn.test_transaction::<_, (), _>(|| {
let (_, users, blogs) = fill_database(&r);
let (_, users, blogs) = fill_database(&conn);
let post = Post::insert(
conn,
&conn,
NewPost {
blog_id: blogs[0].id,
slug: "yo".into(),
@@ -909,19 +908,19 @@ mod tests {
)
.unwrap();
PostAuthor::insert(
conn,
&conn,
NewPostAuthor {
post_id: post.id,
author_id: users[0].id,
},
)
.unwrap();
let create = post.create_activity(conn).unwrap();
post.delete(conn).unwrap();
let create = post.create_activity(&conn).unwrap();
post.delete(&conn).unwrap();
match inbox(&r, serde_json::to_value(create).unwrap()).unwrap() {
match inbox(&conn, serde_json::to_value(create).unwrap()).unwrap() {
InboxResult::Post(p) => {
assert!(p.is_author(conn, users[0].id).unwrap());
assert!(p.is_author(&conn, users[0].id).unwrap());
assert_eq!(p.source, "Hello".to_owned());
assert_eq!(p.blog_id, blogs[0].id);
assert_eq!(p.content, SafeString::new("Hello"));