Add unit tests for main model parts (#310)

Add tests for following models:
- Blog
- Instance
- Media
- User
This commit is contained in:
fdb-hiroshima
2018-11-24 12:44:17 +01:00
committed by Baptiste Gelez
parent 0b9727ed28
commit 8a4702df92
30 changed files with 3779 additions and 1123 deletions
Executable → Regular
+13 -10
View File
@@ -1,11 +1,11 @@
use canapi::{Error, Provider};
use chrono::NaiveDateTime;
use diesel::{self, RunQueryDsl, QueryDsl, ExpressionMethods};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use plume_api::apps::AppEndpoint;
use plume_common::utils::random_hex;
use Connection;
use schema::apps;
use Connection;
#[derive(Clone, Queryable)]
pub struct App {
@@ -19,7 +19,7 @@ pub struct App {
}
#[derive(Insertable)]
#[table_name= "apps"]
#[table_name = "apps"]
pub struct NewApp {
pub name: String,
pub client_id: String,
@@ -43,13 +43,16 @@ impl Provider<Connection> for App {
let client_id = random_hex();
let client_secret = random_hex();
let app = App::insert(conn, NewApp {
name: data.name,
client_id: client_id,
client_secret: client_secret,
redirect_uri: data.redirect_uri,
website: data.website,
});
let app = App::insert(
conn,
NewApp {
name: data.name,
client_id: client_id,
client_secret: client_secret,
redirect_uri: data.redirect_uri,
website: data.website,
},
);
Ok(AppEndpoint {
id: Some(app.id),