Don't remove records after testing

This commit is contained in:
Kitaiti Makoto 2021-01-24 22:31:57 +09:00
parent 4ef6561cc6
commit b5eb2628f9
2 changed files with 2 additions and 14 deletions

View File

@ -151,11 +151,6 @@ mod tests {
searcher.search_document(&conn, Query::from_str(&title).unwrap(), (0, 1))[0].id,
post_id
);
// TODO: Make sure records are deleted even when assertion failed
post.delete(&conn).unwrap();
blog.delete(&conn).unwrap();
user.delete(&conn).unwrap();
diesel::delete(&instance).execute(&conn).unwrap();
}
fn fill_database(conn: &Conn) -> (Instance, User, Blog) {

View File

@ -375,7 +375,7 @@ pub fn atom_feed(name: String, rockets: PlumeRocket) -> Option<Content<String>>
#[cfg(test)]
mod tests {
use crate::init_rocket;
use diesel::{Connection, RunQueryDsl};
use diesel::Connection;
use plume_common::utils::random_hex;
use plume_models::{
blog_authors::{BlogAuthor, NewBlogAuthor},
@ -399,7 +399,7 @@ mod tests {
let dbpool = client.rocket().state::<DbPool>().unwrap();
let conn = &DbConn(dbpool.get().unwrap());
let (instance, user, blog, post) = create_models(conn);
let (_instance, user, blog, post) = create_models(conn);
let blog_path = format!("/~/{}", blog.fqn);
let edit_link = format!(r#"href="{}/{}/edit""#, blog_path, post.slug);
@ -413,13 +413,6 @@ mod tests {
let mut response = request.dispatch();
let body = response.body_string().unwrap();
assert!(body.contains(&edit_link));
post.delete(conn).unwrap();
blog.delete(conn).unwrap();
user.delete(conn).unwrap();
diesel::delete(&instance)
.execute(&dbpool.get().unwrap())
.unwrap();
}
fn create_models(conn: &DbConn) -> (Instance, User, Blog, Post) {