forked from congomongo/congomongo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi-key indexes respect key order, instead of using alphabetical or…
…der. Oops.
- Loading branch information
1 parent
3cc45ec
commit d0be2f8
Showing
3 changed files
with
35 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns somnium.congomongo.test.coerce | ||
(:use somnium.congomongo.coerce) | ||
(:use clojure.test) | ||
(:import (com.mongodb BasicDBObject) )) | ||
|
||
;; insertion order is important for BasicDBObjects, since they extend | ||
;; LinkedHashMap. The only way to test this is to compare their JSON | ||
;; serializations, accessible through .toString | ||
(deftest test-coerce-index-fields | ||
(are [fields bdo] (is (= (.toString (coerce-index-fields fields)) | ||
(.toString bdo))) | ||
[:a :b :c] (doto (BasicDBObject.) | ||
(.put "a" 1) | ||
(.put "b" 1) | ||
(.put "c" 1)) | ||
[:c :b :a] (doto (BasicDBObject.) | ||
(.put "c" 1) | ||
(.put "b" 1) | ||
(.put "a" 1)) | ||
[:a [:b -1] :c] (doto (BasicDBObject.) | ||
(.put "a" 1) | ||
(.put "b" -1) | ||
(.put "c" 1)) | ||
[:c :b [:a -1]] (doto (BasicDBObject.) | ||
(.put "c" 1) | ||
(.put "b" 1) | ||
(.put "a" -1)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters