diff --git a/src/monger/command.clj b/src/monger/command.clj index 7b0fcf5..630abf2 100644 --- a/src/monger/command.clj +++ b/src/monger/command.clj @@ -9,39 +9,38 @@ ;; 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 ([collection] - (collection-stats monger.core/*mongodb-database* collection)) + (collection-stats monger.core/*mongodb-database* collection)) ([^DB database collection] - (monger.core/command database { :collstats collection }))) + (monger.core/command database { :collstats collection }))) (defn db-stats ([] - (db-stats monger.core/*mongodb-database*)) + (db-stats monger.core/*mongodb-database*)) ([^DB database] - (monger.core/command database {:dbStats 1 }))) + (monger.core/command database {:dbStats 1 }))) (defn reindex-collection ([collection] - (reindex-collection monger.core/*mongodb-database* collection)) + (reindex-collection monger.core/*mongodb-database* collection)) ([^DB database collection] - (monger.core/command database { :reIndex collection }))) + (monger.core/command database { :reIndex collection }))) (defn server-status ([] - (server-status monger.core/*mongodb-database*)) + (server-status monger.core/*mongodb-database*)) ([^DB database] - (monger.core/command database {:serverStatus 1 }))) + (monger.core/command database {:serverStatus 1 }))) -(defn top [] - (monger.core/command (monger.core/get-db "admin") {:top 1 })) +(defn top + [] + (monger.core/command (monger.core/get-db "admin") {:top 1})) diff --git a/test/monger/test/command_test.clj b/test/monger/test/command_test.clj index c395dec..6eb8b03 100644 --- a/test/monger/test/command_test.clj +++ b/test/monger/test/command_test.clj @@ -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"))))