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