2018-11-01 21:23:38 +00:00
|
|
|
use diesel::Connection;
|
2019-04-29 14:30:20 +00:00
|
|
|
use plume_common::utils::random_hex;
|
|
|
|
use plume_models::migrations::IMPORTED_MIGRATIONS;
|
2019-03-21 09:30:33 +00:00
|
|
|
use plume_models::{Connection as Conn, CONFIG};
|
2018-11-01 21:23:38 +00:00
|
|
|
|
2019-04-29 14:30:20 +00:00
|
|
|
use std::env::temp_dir;
|
2018-11-07 14:50:24 +00:00
|
|
|
|
2018-11-01 21:23:38 +00:00
|
|
|
fn db() -> Conn {
|
2019-03-22 18:51:36 +00:00
|
|
|
let conn =
|
|
|
|
Conn::establish(CONFIG.database_url.as_str()).expect("Couldn't connect to the database");
|
2019-04-29 14:30:20 +00:00
|
|
|
let dir = temp_dir().join(format!("plume-test-{}", random_hex()));
|
|
|
|
IMPORTED_MIGRATIONS
|
|
|
|
.run_pending_migrations(&conn, &dir)
|
|
|
|
.expect("Couldn't run migrations");
|
2018-11-01 21:23:38 +00:00
|
|
|
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
|
|
|
}
|