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