More cleanup
This commit is contained in:
parent
971b2e230c
commit
d04ab3af2d
2 changed files with 32 additions and 36 deletions
|
|
@ -9,11 +9,9 @@
|
|||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns monger.command
|
||||
(:use [monger.conversion])
|
||||
(:refer-clojure :exclude [find remove count drop distinct empty?])
|
||||
(:import [com.mongodb Mongo DB DBObject CommandResult]
|
||||
[java.util Map])
|
||||
(:require [monger core]))
|
||||
(:require monger.core)
|
||||
(:use monger.conversion)
|
||||
(:import com.mongodb.DB))
|
||||
|
||||
|
||||
(defn collection-stats
|
||||
|
|
@ -43,5 +41,6 @@
|
|||
(monger.core/command database {:serverStatus 1 })))
|
||||
|
||||
|
||||
(defn top []
|
||||
(defn top
|
||||
[]
|
||||
(monger.core/command (monger.core/get-db "admin") {:top 1}))
|
||||
|
|
|
|||
|
|
@ -1,44 +1,41 @@
|
|||
(ns monger.test.command-test
|
||||
(:require [monger core command]
|
||||
(:require [monger.command :as mcom]
|
||||
[monger.test.helper :as helper]
|
||||
[monger.collection :as mgcol])
|
||||
(:import (com.mongodb Mongo DB CommandResult))
|
||||
(:use clojure.test))
|
||||
[monger.collection :as mc])
|
||||
(:use clojure.test
|
||||
monger.result))
|
||||
|
||||
(helper/connect!)
|
||||
|
||||
|
||||
(deftest test-db-stats
|
||||
(let [stats (monger.command/db-stats)]
|
||||
(is (monger.result/ok? stats))
|
||||
(let [stats (mcom/db-stats)]
|
||||
(is (ok? stats))
|
||||
(is (= "monger-test" (get stats "db")))))
|
||||
|
||||
(deftest test-collection-stats
|
||||
(let [collection "stat_test"
|
||||
_ (mgcol/insert collection { :name "Clojure" })
|
||||
check (mgcol/count collection)
|
||||
stats (monger.command/collection-stats collection)]
|
||||
(is (monger.result/ok? stats))
|
||||
_ (mc/insert collection {:name "Clojure"})
|
||||
check (mc/count collection)
|
||||
stats (mcom/collection-stats collection)]
|
||||
(is (ok? stats))
|
||||
(is (= "monger-test.stat_test" (get stats "ns")))
|
||||
(is (= check (get stats "count")))))
|
||||
|
||||
|
||||
(deftest test-reindex-collection
|
||||
(let [_ (mgcol/insert "test" { :name "Clojure" })
|
||||
result (monger.command/reindex-collection "test")]
|
||||
(is (monger.result/ok? result))
|
||||
(let [_ (mc/insert "test" {:name "Clojure"})
|
||||
result (mcom/reindex-collection "test")]
|
||||
(is (ok? result))
|
||||
(is (get result "indexes"))))
|
||||
|
||||
|
||||
(deftest test-server-status
|
||||
(let [status (monger.command/server-status)]
|
||||
(is (monger.result/ok? status))
|
||||
(let [status (mcom/server-status)]
|
||||
(is (ok? status))
|
||||
(is (not-empty status))
|
||||
(is (get status "serverUsed"))))
|
||||
|
||||
|
||||
(deftest test-top
|
||||
(let [result (monger.command/top)]
|
||||
(is (monger.result/ok? result))
|
||||
(let [result (mcom/top)]
|
||||
(is (ok? result))
|
||||
(is (not-empty result))
|
||||
(is (get result "serverUsed"))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue