Browse Source

tests extended

master
Christian Mueller 12 years ago
parent
commit
3231271744
  1. 1
      .gitignore
  2. 2
      src/NoteHub/storage.clj
  3. 6
      test/NoteHub/test/api.clj

1
.gitignore vendored

@ -8,3 +8,4 @@ pom.xml @@ -8,3 +8,4 @@ pom.xml
.lein-*
.crossover-cljs
target/
.nrepl-port

2
src/NoteHub/storage.clj

@ -96,7 +96,7 @@ @@ -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) })

6
test/NoteHub/test/api.clj

@ -41,7 +41,10 @@ @@ -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 @@ @@ -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")]

Loading…
Cancel
Save