Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Commit

Permalink
Add tests for preserve meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuu Shimizu committed Apr 19, 2012
1 parent efadf77 commit abdbc2a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/mongoika/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,37 @@
(is (nil? (object-id<- "iuefgiauofhia")))
(is (nil? (object-id<- 3123456157))))

(deftest* preserve-meta-test
(with-test-db-binding
(insert-multi! :fruits {:name "Banana" :price 200} {:name "Apple" :price 100})
(is (= "fruits" (-> (with-meta (query :fruits) {::name "fruits"})
meta
::name)))
(is (= "fruits2" (->> (with-meta (query :fruits) {::name "fruits2"})
(restrict :name "Banana")
meta
::name)))
(is (= "fruits3" (->> (with-meta (query :fruits) {::label "fruits3"})
(project :name)
meta
::label)))
(is (= "fruits4" (->> (with-meta (query :fruits) {::label "fruits4"})
(order :price :asc)
meta
::label)))
(is (= "fruits5" (->> (with-meta (query :fruits) {::tag "fruits5"})
(skip 1)
meta
::tag)))
(is (= "fruits6" (->> (with-meta (query :fruits) {::tag "fruits6"})
(limit 1)
meta
::tag)))
(is (= "fruits7" (->> (with-meta (query :fruits) {::key "fruits7"})
(map-after #(assoc % :tax (* (:price %) 0.1)))
meta
::key)))))

(use-fixtures :each #(time (%)))

;; (time (run-tests))

0 comments on commit abdbc2a

Please sign in to comment.