Add unit tests for main model parts (#310)
Add tests for following models: - Blog - Instance - Media - User
This commit is contained in:
committed by
Baptiste Gelez
parent
0b9727ed28
commit
8a4702df92
@@ -1,15 +1,11 @@
|
||||
extern crate diesel;
|
||||
#[macro_use] extern crate diesel_migrations;
|
||||
#[macro_use]
|
||||
extern crate diesel_migrations;
|
||||
|
||||
extern crate plume_models;
|
||||
|
||||
use diesel::Connection;
|
||||
use plume_models::{
|
||||
DATABASE_URL,
|
||||
Connection as Conn,
|
||||
instance::*,
|
||||
safe_string::SafeString,
|
||||
};
|
||||
use plume_models::{Connection as Conn, DATABASE_URL};
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
embed_migrations!("../migrations/sqlite");
|
||||
@@ -24,24 +20,7 @@ fn db() -> Conn {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn instance_insert() {
|
||||
fn empty_test() {
|
||||
let conn = &db();
|
||||
conn.test_transaction::<_, (), _>(|| {
|
||||
Instance::insert(conn, NewInstance {
|
||||
default_license: "WTFPL".to_string(),
|
||||
local: true,
|
||||
long_description: SafeString::new("This is my instance."),
|
||||
long_description_html: "<p>This is my instance</p>".to_string(),
|
||||
short_description: SafeString::new("My instance."),
|
||||
short_description_html: "<p>My instance</p>".to_string(),
|
||||
name: "My instance".to_string(),
|
||||
open_registrations: true,
|
||||
public_domain: "plu.me".to_string(),
|
||||
});
|
||||
let inst = Instance::get_local(conn);
|
||||
assert!(inst.is_some());
|
||||
let inst = inst.unwrap();
|
||||
assert_eq!(inst.name, "My instance".to_string());
|
||||
Ok(())
|
||||
});
|
||||
conn.test_transaction::<_, (), _>(|| Ok(()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user