monger.command tests now pass
This commit is contained in:
parent
ab4a9a381f
commit
d114073413
1 changed files with 23 additions and 25 deletions
|
|
@ -1,36 +1,34 @@
|
||||||
(ns monger.test.command-test
|
(ns monger.test.command-test
|
||||||
(:require [monger.core :as mg]
|
(:require [monger.core :as mg]
|
||||||
[monger.command :as mcom]
|
[monger.command :as mcom]
|
||||||
[monger.test.helper :as helper]
|
|
||||||
[monger.collection :as mc]
|
[monger.collection :as mc]
|
||||||
[clojure.test :refer :all]
|
[clojure.test :refer :all]
|
||||||
[monger.result :refer [ok?]]
|
[monger.result :refer [ok?]]
|
||||||
[monger.conversion :refer [from-db-object]]))
|
[monger.conversion :refer [from-db-object]]))
|
||||||
|
|
||||||
(helper/connect!)
|
(let [conn (mg/connect)
|
||||||
|
db (mg/get-db conn "monger-test")]
|
||||||
|
(deftest ^{:command true} test-reindex-collection
|
||||||
|
(let [_ (mc/insert db "test" {:name "Clojure"})
|
||||||
|
result (mcom/reindex-collection db "test")]
|
||||||
|
(is (ok? result))
|
||||||
|
(is (get result "indexes"))))
|
||||||
|
|
||||||
|
(deftest ^{:command true} test-server-status
|
||||||
|
(let [status (mcom/server-status db)]
|
||||||
|
(is (ok? status))
|
||||||
|
(is (not-empty status))
|
||||||
|
(is (get status "serverUsed"))))
|
||||||
|
|
||||||
(deftest ^{:command true} test-reindex-collection
|
(deftest ^{:command true} test-top
|
||||||
(let [_ (mc/insert "test" {:name "Clojure"})
|
(let [result (mcom/top conn)]
|
||||||
result (mcom/reindex-collection "test")]
|
(is (ok? result))
|
||||||
(is (ok? result))
|
(is (not-empty result))
|
||||||
(is (get result "indexes"))))
|
(is (get result "serverUsed"))))
|
||||||
|
|
||||||
(deftest ^{:command true} test-server-status
|
(deftest ^{:command true} test-running-is-master-as-an-arbitrary-command
|
||||||
(let [status (mcom/server-status)]
|
(let [raw (mg/command db {:isMaster 1})
|
||||||
(is (ok? status))
|
result (from-db-object raw true)]
|
||||||
(is (not-empty status))
|
(is (ok? result))
|
||||||
(is (get status "serverUsed"))))
|
(is (ok? raw))
|
||||||
|
(is (:ismaster result)))))
|
||||||
(deftest ^{:command true} test-top
|
|
||||||
(let [result (mcom/top)]
|
|
||||||
(is (ok? result))
|
|
||||||
(is (not-empty result))
|
|
||||||
(is (get result "serverUsed"))))
|
|
||||||
|
|
||||||
(deftest ^{:command true} test-running-is-master-as-an-arbitrary-command
|
|
||||||
(let [raw (mg/command {:isMaster 1})
|
|
||||||
result (from-db-object raw true)]
|
|
||||||
(is (ok? result))
|
|
||||||
(is (ok? raw))
|
|
||||||
(is (:ismaster result))))
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue