More cleanup

This commit is contained in:
Michael S. Klishin 2012-05-01 16:35:33 +04:00
parent 971b2e230c
commit d04ab3af2d
2 changed files with 32 additions and 36 deletions

View file

@ -9,11 +9,9 @@
;; You must not remove this notice, or any other, from this software. ;; You must not remove this notice, or any other, from this software.
(ns monger.command (ns monger.command
(:use [monger.conversion]) (:require monger.core)
(:refer-clojure :exclude [find remove count drop distinct empty?]) (:use monger.conversion)
(:import [com.mongodb Mongo DB DBObject CommandResult] (:import com.mongodb.DB))
[java.util Map])
(:require [monger core]))
(defn collection-stats (defn collection-stats
@ -43,5 +41,6 @@
(monger.core/command database {:serverStatus 1 }))) (monger.core/command database {:serverStatus 1 })))
(defn top [] (defn top
[]
(monger.core/command (monger.core/get-db "admin") {:top 1})) (monger.core/command (monger.core/get-db "admin") {:top 1}))

View file

@ -1,44 +1,41 @@
(ns monger.test.command-test (ns monger.test.command-test
(:require [monger core command] (:require [monger.command :as mcom]
[monger.test.helper :as helper] [monger.test.helper :as helper]
[monger.collection :as mgcol]) [monger.collection :as mc])
(:import (com.mongodb Mongo DB CommandResult)) (:use clojure.test
(:use clojure.test)) monger.result))
(helper/connect!) (helper/connect!)
(deftest test-db-stats (deftest test-db-stats
(let [stats (monger.command/db-stats)] (let [stats (mcom/db-stats)]
(is (monger.result/ok? stats)) (is (ok? stats))
(is (= "monger-test" (get stats "db"))))) (is (= "monger-test" (get stats "db")))))
(deftest test-collection-stats (deftest test-collection-stats
(let [collection "stat_test" (let [collection "stat_test"
_ (mgcol/insert collection { :name "Clojure" }) _ (mc/insert collection {:name "Clojure"})
check (mgcol/count collection) check (mc/count collection)
stats (monger.command/collection-stats collection)] stats (mcom/collection-stats collection)]
(is (monger.result/ok? stats)) (is (ok? stats))
(is (= "monger-test.stat_test" (get stats "ns"))) (is (= "monger-test.stat_test" (get stats "ns")))
(is (= check (get stats "count"))))) (is (= check (get stats "count")))))
(deftest test-reindex-collection (deftest test-reindex-collection
(let [_ (mgcol/insert "test" { :name "Clojure" }) (let [_ (mc/insert "test" {:name "Clojure"})
result (monger.command/reindex-collection "test")] result (mcom/reindex-collection "test")]
(is (monger.result/ok? result)) (is (ok? result))
(is (get result "indexes")))) (is (get result "indexes"))))
(deftest test-server-status (deftest test-server-status
(let [status (monger.command/server-status)] (let [status (mcom/server-status)]
(is (monger.result/ok? status)) (is (ok? status))
(is (not-empty status)) (is (not-empty status))
(is (get status "serverUsed")))) (is (get status "serverUsed"))))
(deftest test-top (deftest test-top
(let [result (monger.command/top)] (let [result (mcom/top)]
(is (monger.result/ok? result)) (is (ok? result))
(is (not-empty result)) (is (not-empty result))
(is (get result "serverUsed")))) (is (get result "serverUsed"))))