summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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(()));
90aea904686272fb50bb81cea8f60716901b3a'>^
7d2c2d55 ^

4b62edd8 ^
7d2c2d55 ^
ef55a414 ^

02244ae2 ^
ef55a414 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23