From 32312717446e646f28829fc34cfd7e90a1d96a0b Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Thu, 9 Jan 2014 20:37:23 +0100 Subject: [PATCH] tests extended --- .gitignore | 1 + src/NoteHub/storage.clj | 2 +- test/NoteHub/test/api.clj | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b7de877..9aa5ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ pom.xml .lein-* .crossover-cljs target/ +.nrepl-port diff --git a/src/NoteHub/storage.clj b/src/NoteHub/storage.clj index 59e7a50..9123662 100644 --- a/src/NoteHub/storage.clj +++ b/src/NoteHub/storage.clj @@ -96,7 +96,7 @@ (defn get-note-statistics "Return views, publishing and editing timestamp" [noteID] - { :view (redis/hget db views noteID) + { :views (redis/hget db views noteID) :published (redis/hget db published noteID) :edited (redis/hget db edited noteID) }) diff --git a/test/NoteHub/test/api.clj b/test/NoteHub/test/api.clj index 1b2d4f3..8f292a6 100644 --- a/test/NoteHub/test/api.clj +++ b/test/NoteHub/test/api.clj @@ -41,7 +41,10 @@ (is (:success (:status get-response))) (is (= note (:note get-response))) (is (= (:longURL post-response) (:longURL get-response) note-url)) - (is (= (:shortURL post-response) (:shortURL get-response))))) + (is (= (:shortURL post-response) (:shortURL get-response))) + (is (= "1" (get-in get-response [:statistics :views]))) + (isnt (get-in get-response [:statistics :edited])) + (is (= "2" (get-in (get-note (:noteID post-response)) [:statistics :views]))))) (testing "creation with wrong signature" (let [response (post-note note pid (get-signature pid2 psk note))] (isnt (:success (:status response))) @@ -71,6 +74,7 @@ (let [update-response (update-note note-id new-note pid (get-signature pid psk note-id new-note "passwd") "passwd")] (is (= { :success true } (:status update-response))) + (isnt (= nil (get-in (get-note note-id) [:statistics :edited]))) (is (= new-note (:note (get-note note-id))))) (let [update-response (update-note note-id "aaa" pid (get-signature pid psk note-id "aaa" "pass") "pass")]