Test case with child documents embedded into parent now passes
This commit is contained in:
parent
a2eb9ce964
commit
c1409eb81e
2 changed files with 25 additions and 10 deletions
|
|
@ -56,15 +56,22 @@
|
|||
|
||||
|
||||
(defn build
|
||||
"Generates a new document and returns it"
|
||||
[f-group f-name & { :as overrides }]
|
||||
(let [d (@defaults (name f-group))
|
||||
attributes (get-in @factories [(name f-group) (name f-name)])]
|
||||
(expand-all (merge { :_id (ObjectId.) } d attributes overrides))))
|
||||
|
||||
(defn seed
|
||||
"Generates and inserts a new document, then returns it"
|
||||
[f-group f-name & { :as overrides }]
|
||||
(io!
|
||||
(let [doc (apply build f-group f-name (flatten (vec overrides)))
|
||||
oid (:_id doc)]
|
||||
(assert (mr/ok? (mc/insert f-group doc)))
|
||||
doc)))
|
||||
(let [doc (apply build f-group f-name (flatten (vec overrides)))
|
||||
oid (:_id doc)]
|
||||
(assert (mr/ok? (mc/insert f-group doc)))
|
||||
doc)))
|
||||
|
||||
(defn embedded-doc
|
||||
[f-group f-name & { :as overrides }]
|
||||
(fn []
|
||||
(apply build f-group f-name (flatten (vec overrides)))))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
|
||||
(factory "domains" "clojure"
|
||||
:name "clojure.org"
|
||||
:created-at (-> 2 days ago))
|
||||
:created-at (-> 2 days ago)
|
||||
:embedded [(embedded-doc "pages" "http://clojure.org/lisp")
|
||||
(embedded-doc "pages" "http://clojure.org/jvm_hosted")
|
||||
(embedded-doc "pages" "http://clojure.org/runtime_polymorphism")])
|
||||
|
||||
(factory "domains" "elixir"
|
||||
:name "elixir-lang.org"
|
||||
|
|
@ -31,10 +34,13 @@
|
|||
})
|
||||
|
||||
(factory "pages" "http://clojure.org/rationale"
|
||||
:name "/rationale"
|
||||
:created-at (-> 2 days ago)
|
||||
;; :domain-id (parent-id "domains" "clojure")
|
||||
)
|
||||
:name "/rationale")
|
||||
(factory "pages" "http://clojure.org/jvm_hosted"
|
||||
:name "/jvm_hosted")
|
||||
(factory "pages" "http://clojure.org/runtime_polymorphism"
|
||||
:name "/runtime_polymorphism")
|
||||
(factory "pages" "http://clojure.org/lisp"
|
||||
:name "/lisp")
|
||||
|
||||
(deftest test-building-documents-from-a-factory-case-1
|
||||
(let [t (-> 2 weeks ago)
|
||||
|
|
@ -58,7 +64,9 @@
|
|||
(is (= oid (:_id doc)))
|
||||
(is (= t (:created-at doc)))
|
||||
(is (= "clojurewerkz.org" (:name doc)))
|
||||
(is (:ipv6-enabled doc))))
|
||||
(is (:ipv6-enabled doc))
|
||||
(is (= ["/lisp" "/jvm_hosted" "/runtime_polymorphism"]
|
||||
(vec (map :name (:embedded doc)))))))
|
||||
|
||||
|
||||
(deftest test-building-documents-from-a-factory-case-4
|
||||
|
|
|
|||
Loading…
Reference in a new issue