From 251f72e29ee333196c31224f506649dbfc15cc41 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Wed, 28 Aug 2019 15:31:35 -0400 Subject: db tests are on separate path --- src/db.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/db.rs b/src/db.rs index a63c64a..f892c10 100644 --- a/src/db.rs +++ b/src/db.rs @@ -18,11 +18,11 @@ pub struct Conn { } impl Conn { - fn init() -> rusqlite::Connection { + fn init(path: &str) -> rusqlite::Connection { let start = time::Instant::now(); info!("Connecting to database"); let conn = rusqlite::Connection::open_with_flags( - DB_PATH, + path, rusqlite::OpenFlags::SQLITE_OPEN_FULL_MUTEX | rusqlite::OpenFlags::SQLITE_OPEN_CREATE | rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE, @@ -49,7 +49,9 @@ impl Conn { } pub fn new() -> Self { - Conn { conn: Conn::init() } + Conn { + conn: Conn::init(DB_PATH), + } } } @@ -59,7 +61,7 @@ mod tests { #[test] fn test_new() { - let conn = Conn::init(); + let conn = Conn::init("/tmp/clinte-test.db"); let mut stmt = conn.prepare("SELECT * FROM POSTS").unwrap(); stmt.query_map(rusqlite::NO_PARAMS, |row| Ok(())); -- cgit 1.4.1-2-gfad0