2018-11-01 22:23:38 +01:00
|
|
|
extern crate diesel;
|
2018-11-24 12:44:17 +01:00
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel_migrations;
|
2018-11-01 22:23:38 +01:00
|
|
|
|
|
|
|
extern crate plume_models;
|
|
|
|
|
|
|
|
use diesel::Connection;
|
2018-11-24 12:44:17 +01:00
|
|
|
use plume_models::{Connection as Conn, DATABASE_URL};
|
2018-11-01 22:23:38 +01:00
|
|
|
|
2018-11-07 15:50:24 +01:00
|
|
|
#[cfg(feature = "sqlite")]
|
2018-11-01 22:23:38 +01:00
|
|
|
embed_migrations!("../migrations/sqlite");
|
|
|
|
|
2018-11-07 15:50:24 +01:00
|
|
|
#[cfg(feature = "postgres")]
|
|
|
|
embed_migrations!("../migrations/postgres");
|
|
|
|
|
2018-11-01 22:23:38 +01:00
|
|
|
fn db() -> Conn {
|
2018-11-07 15:50:24 +01:00
|
|
|
let conn = Conn::establish(&*DATABASE_URL.as_str()).expect("Couldn't connect to the database");
|
2018-11-01 22:23:38 +01:00
|
|
|
embedded_migrations::run(&conn).expect("Couldn't run migrations");
|
|
|
|
conn
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2018-11-24 12:44:17 +01:00
|
|
|
fn empty_test() {
|
2018-11-01 22:23:38 +01:00
|
|
|
let conn = &db();
|
2018-11-24 12:44:17 +01:00
|
|
|
conn.test_transaction::<_, (), _>(|| Ok(()));
|
2018-11-01 22:23:38 +01:00
|
|
|
}
|