summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db.rs2
-rw-r--r--src/posts.rs7
2 files changed, 6 insertions, 3 deletions
diff --git a/src/db.rs b/src/db.rs
index b79a789..d09ce21 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -18,7 +18,7 @@ pub struct Conn {
 }
 
 impl Conn {
-    fn init(path: &str) -> rusqlite::Connection {
+    pub fn init(path: &str) -> rusqlite::Connection {
         let start = time::Instant::now();
         info!("Connecting to database");
         let conn = rusqlite::Connection::open_with_flags(
diff --git a/src/posts.rs b/src/posts.rs
index 88368a6..698f8a6 100644
--- a/src/posts.rs
+++ b/src/posts.rs
@@ -42,7 +42,8 @@ mod tests {
 
     #[test]
     fn post_new() {
-        let db = db::Conn::new();
+        let db = db::Conn::init("/tmp/clinte.db");
+        let db = db::Conn { conn: db };
         let mut stmt = db
             .conn
             .prepare("INSERT INTO posts (title, author, body) VALUES (:title, :author, :body)")
@@ -51,16 +52,18 @@ mod tests {
         let title = String::from("TEST TITLE");
 
         new(&mut stmt, &title, "TEST BODY").unwrap();
+        update("NEW TITLE", "TEST BODY", 1, &db).unwrap();
 
         let mut stmt = db
             .conn
             .prepare("SELECT * FROM posts WHERE title = :title")
             .unwrap();
 
+        let title = String::from("NEW TITLE");
         let out: String = stmt
             .query_row_named(&[(":title", &title)], |row| row.get::<usize, String>(1))
             .unwrap();
 
-        assert_eq!("TEST TITLE", &out);
+        assert_eq!("NEW TITLE", &out);
     }
 }
/colorschemes.txt?id=a8f9cf2c8bcd2432b1b82a68422102a6924864d6'>a8f9cf2c ^
efdc7b16 ^

a2853ab6 ^
f597489c ^
efdc7b16 ^
29b05d00 ^


efdc7b16 ^
f597489c ^


efdc7b16 ^

a8f9cf2c ^

efdc7b16 ^






f597489c ^
efdc7b16 ^




23905709 ^
efdc7b16 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92