Skip to content
This repository has been archived by the owner on Jan 11, 2020. It is now read-only.

Commit

Permalink
Implemented clean-db! function.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfm committed Sep 21, 2012
1 parent 9ca6d0e commit 54d3c28
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(defproject judgr/mongodb "0.1.2"
(defproject judgr/mongodb "0.1.3"
:description "MongoDB support for Judgr."
:url "http://github.com/danielfm/judgr-mongodb"
:dependencies [[judgr "0.2.0"]
:dependencies [[judgr "0.2.1"]
[congomongo "0.1.7"]]
:dev-dependencies [[lein-clojars "0.7.0"]])
5 changes: 5 additions & 0 deletions src/judgr/mongo/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
(str (name :classes) "." (name class)) 1}})
(.get-feature db feature))))

(clean-db! [db]
(mongodb/with-mongo conn
(mongodb/destroy! :items {})
(mongodb/destroy! :features {})))

(get-feature [db feature]
(mongodb/with-mongo conn
(let [feature (mongodb/fetch-one :features
Expand Down
11 changes: 2 additions & 9 deletions test/judgr/mongo/test/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,14 @@
[:database :type] :mongo
[:database :mongo :database] "judgr-test"))

(defn- clean-db!
"Removes all documents from the database."
[db]
(mongodb/with-mongo (.get-connection db)
(mongodb/destroy! :items {})
(mongodb/destroy! :features {})))

(def-fixture empty-db []
(let [db (db-from new-settings)]
(clean-db! db)
(.clean-db! db)
(test-body)))

(def-fixture basic-db []
(let [db (db-from new-settings)]
(clean-db! db)
(.clean-db! db)
(.add-item! db "Some message" :positive)
(.add-item! db "Another message" :positive)
(.add-feature! db "Some message" "message" :positive)
Expand Down

0 comments on commit 54d3c28

Please sign in to comment.