Skip to content

Commit d80d745

Browse files
committed
Merge pull request #157 from anthonygalea/master
Add tests for reduce, http. Relates to #117.
2 parents a8ff4af + a15cc2b commit d80d745

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/rethinkdb/core_test.clj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@
212212
(r/ungroup (r/group [1 6 1 8] (r/fn [e] e))) [{:group 1, :reduction [1 1]}
213213
{:group 6, :reduction [6]}
214214
{:group 8, :reduction [8]}]
215+
(r/reduce [1] (r/fn [a b] (r/add a b))) 1
216+
(r/reduce [1 6 1 8] (r/fn [a b] (r/add a b))) 16
215217
(r/count [1 6 1 8]) 4
216218
(r/count "asdf") 4
217219
(r/count {:a 1 :b 2 :c 3}) 3
@@ -313,10 +315,10 @@
313315
(r/has-fields a :y) [(first a)])))
314316

315317
(testing "literal-values"
316-
(with-open [conn (r/connect)]
317-
(is (= (r/run (r/object :a 1) conn) {:a 1}))
318-
(is (= (r/run (r/keys (r/object :a 1)) conn) ["a"]))
319-
(is (= (r/run (r/values (r/object :a 1)) conn) [1]))))))
318+
(are [term result] (= (r/run term conn) result)
319+
(r/object :a 1) {:a 1}
320+
(r/keys (r/object :a 1)) ["a"]
321+
(r/values (r/object :a 1)) [1]))))
320322

321323
(deftest string-manipulation
322324
(with-open [conn (r/connect)]
@@ -392,7 +394,8 @@
392394
(r/coerce-to "1" "NUMBER") 1
393395
(r/type-of [1 2 3]) "ARRAY"
394396
(r/type-of {:number 42}) "OBJECT"
395-
(r/json "{\"number\":42}") {:number 42})))
397+
(r/json "{\"number\":42}") {:number 42})
398+
(is (= (:url (r/run (r/http "http://httpbin.org/get") conn)) "http://httpbin.org/get"))))
396399

397400
(deftest math-and-logic
398401
(with-open [conn (r/connect)]
@@ -647,4 +650,4 @@
647650
:image (bs/to-byte-array file)})
648651
(r/run conn))
649652
(let [resp (-> (r/table "pokedex") (r/run conn) first :image)]
650-
(is (= (String. resp "UTF-8") (String. (bs/to-byte-array file) "UTF-8")))))))
653+
(is (= (String. ^bytes resp "UTF-8") (String. (bs/to-byte-array file) "UTF-8")))))))

0 commit comments

Comments
 (0)