summary refs log tree commit diff stats
path: root/src/db.rs
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-08-28 15:31:35 -0400
committerBen Morrison <ben@gbmor.dev>2019-08-28 15:31:35 -0400
commit251f72e29ee333196c31224f506649dbfc15cc41 (patch)
tree57eee3050f190e33db5581127c00319f181eed1f /src/db.rs
parent929b5dc0e3c01bb6c9ca4002c6b907dae508ec23 (diff)
downloadclinte-251f72e29ee333196c31224f506649dbfc15cc41.tar.gz
db tests are on separate path
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs10
1 files changed, 6 insertions, 4 deletions
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(()));