 
 (deftest test-parse-fields
   (let [parsed? (fn [fields expected-parsed-fields]
-                  (is (= (parse-fields fields) expected-parsed-fields)))]
+                  (expect (parse-fields fields) =>  expected-parsed-fields))]
     (testing "empty fields"
           (parsed? nil {}))
     (testing "no type specified"

                      (set-reference :ceo john)
                      (add-reference :employees jane)
                      save)]
      (is (= (:_id john) (:ceo company)))
      (is (= (:_id jane) (first (:employees company))))))
  (testing "reading"
    (let [company (fetch-one Company (where (eq :name "Acme")))
          john (get-reference company :ceo)
          [jane] (get-reference company :employees)]
      (is (= "Smith" (:last-name john)))
      (is (= "Doe" (:last-name jane)))))
  (testing "updating"
    (let [bill (create Person {:first-name "Bill" :last-name "Jones"})
          company (-> (fetch-one Company (where (eq :name "Acme")))
                      (add-reference :employees bill))
          [jane bill] (get-reference company :employees)]
      (is (= "Jane" (:first-name jane)))
      (is (= "Bill" (:first-name bill))))))

(deftest test-deffetch
  (is (= {:older-companies older-companies

(deftest test-find-and-*
  (let [foo (create Simple {:value "Foo"})
        expected (merge foo {:age 21})]
    (expect (find-and-modify Simple (where (eq :value "Foo"))
                             (modify (set-fields {:age 21}))
                             :return-new true)
            => expected)
    (expect (find-and-remove Simple (where (eq :value "Foo")))
            => expected)))

(deftest test-map-reduce
  (dotimes [n 5]
    (create Simple {:value n}))
  (expect (map-reduce-fetch-all Simple
                                "function() {emit('sum', this.value)}"
                                "function(k,vals) {
                                    var sum=0;
                                    for(var i in vals) sum += vals[i];
                                    return sum;
                                 }")
                  => [{:_id "sum" :value (apply + (range 5))}]))
