Cosmetics
This commit is contained in:
parent
74589346d0
commit
1c686c1766
1 changed files with 18 additions and 18 deletions
|
|
@ -3,13 +3,13 @@
|
||||||
org.bson.types.ObjectId
|
org.bson.types.ObjectId
|
||||||
java.util.Date)
|
java.util.Date)
|
||||||
(:require [monger core util]
|
(:require [monger core util]
|
||||||
[monger.collection :as mgcol]
|
[monger.collection :as mc]
|
||||||
[monger.result :as mgres]
|
[monger.result :as mgres]
|
||||||
[monger.js :as js]
|
[clojurewerkz.support.js :as js]
|
||||||
[monger.test.helper :as helper])
|
[monger.test.helper :as helper])
|
||||||
(:use clojure.test
|
(:use clojure.test
|
||||||
[monger operators conversion]
|
[monger operators conversion]
|
||||||
[monger.test.fixtures]))
|
monger.test.fixtures))
|
||||||
|
|
||||||
(helper/connect!)
|
(helper/connect!)
|
||||||
|
|
||||||
|
|
@ -36,34 +36,34 @@
|
||||||
{ :state "IL" :quantity 3 :price 5.50 }]
|
{ :state "IL" :quantity 3 :price 5.50 }]
|
||||||
expected [{:_id "CA", :value 204.9} {:_id "IL", :value 39.5} {:_id "NY", :value 697.0}]]
|
expected [{:_id "CA", :value 204.9} {:_id "IL", :value 39.5} {:_id "NY", :value 697.0}]]
|
||||||
(deftest test-basic-inline-map-reduce-example
|
(deftest test-basic-inline-map-reduce-example
|
||||||
(mgcol/remove monger.core/*mongodb-database* collection {})
|
(mc/remove monger.core/*mongodb-database* collection {})
|
||||||
(is (mgres/ok? (mgcol/insert-batch collection batch)))
|
(is (mgres/ok? (mc/insert-batch collection batch)))
|
||||||
(let [output (mgcol/map-reduce collection mapper reducer nil MapReduceCommand$OutputType/INLINE {})
|
(let [output (mc/map-reduce collection mapper reducer nil MapReduceCommand$OutputType/INLINE {})
|
||||||
results (from-db-object ^DBObject (.results ^MapReduceOutput output) true)]
|
results (from-db-object ^DBObject (.results ^MapReduceOutput output) true)]
|
||||||
(mgres/ok? output)
|
(mgres/ok? output)
|
||||||
(is (= expected results))))
|
(is (= expected results))))
|
||||||
|
|
||||||
(deftest test-basic-map-reduce-example-that-replaces-named-collection
|
(deftest test-basic-map-reduce-example-that-replaces-named-collection
|
||||||
(mgcol/remove monger.core/*mongodb-database* collection {})
|
(mc/remove monger.core/*mongodb-database* collection {})
|
||||||
(is (mgres/ok? (mgcol/insert-batch collection batch)))
|
(is (mgres/ok? (mc/insert-batch collection batch)))
|
||||||
(let [output (mgcol/map-reduce collection mapper reducer "mr_outputs" {})
|
(let [output (mc/map-reduce collection mapper reducer "mr_outputs" {})
|
||||||
results (from-db-object ^DBObject (.results ^MapReduceOutput output) true)]
|
results (from-db-object ^DBObject (.results ^MapReduceOutput output) true)]
|
||||||
(mgres/ok? output)
|
(mgres/ok? output)
|
||||||
(is (= 3 (monger.core/count results)))
|
(is (= 3 (monger.core/count results)))
|
||||||
(is (= expected
|
(is (= expected
|
||||||
(map #(from-db-object % true) (seq results))))
|
(map #(from-db-object % true) (seq results))))
|
||||||
(is (= expected
|
(is (= expected
|
||||||
(map #(from-db-object % true) (mgcol/find "mr_outputs"))))
|
(map #(from-db-object % true) (mc/find "mr_outputs"))))
|
||||||
(.drop ^MapReduceOutput output)))
|
(.drop ^MapReduceOutput output)))
|
||||||
|
|
||||||
(deftest test-basic-map-reduce-example-that-merged-results-into-named-collection
|
(deftest test-basic-map-reduce-example-that-merged-results-into-named-collection
|
||||||
(mgcol/remove monger.core/*mongodb-database* collection {})
|
(mc/remove monger.core/*mongodb-database* collection {})
|
||||||
(is (mgres/ok? (mgcol/insert-batch collection batch)))
|
(is (mgres/ok? (mc/insert-batch collection batch)))
|
||||||
(mgcol/map-reduce collection mapper reducer "merged_mr_outputs" MapReduceCommand$OutputType/MERGE {})
|
(mc/map-reduce collection mapper reducer "merged_mr_outputs" MapReduceCommand$OutputType/MERGE {})
|
||||||
(is (mgres/ok? (mgcol/insert collection { :state "OR" :price 17.95 :quantity 4 })))
|
(is (mgres/ok? (mc/insert collection { :state "OR" :price 17.95 :quantity 4 })))
|
||||||
(let [^MapReduceOutput output (mgcol/map-reduce collection mapper reducer "merged_mr_outputs" MapReduceCommand$OutputType/MERGE {})]
|
(let [^MapReduceOutput output (mc/map-reduce collection mapper reducer "merged_mr_outputs" MapReduceCommand$OutputType/MERGE {})]
|
||||||
(mgres/ok? output)
|
(mgres/ok? output)
|
||||||
(is (= 4 (monger.core/count output)))
|
(is (= 4 (monger.core/count output)))
|
||||||
(is (= ["CA" "IL" "NY" "OR"]
|
(is (= ["CA" "IL" "NY" "OR"]
|
||||||
(map :_id (mgcol/find-maps "merged_mr_outputs"))))
|
(map :_id (mc/find-maps "merged_mr_outputs"))))
|
||||||
(.drop ^MapReduceOutput output))))
|
(.drop ^MapReduceOutput output))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue