Skip to content

Commit b58b1c8

Browse files
committed
Merge pull request #152 from anthonygalea/master
Add tests for group, ungroup, count, distinct. Relates to #117.
2 parents dc4b491 + a6e066e commit b58b1c8

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. This change
55
## [Unreleased]
66
### Changed
77
- Renamed indexes-of to offsets-of.
8+
89
### Added
910
- Added range.
1011

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:src-dir-uri "https://github.com/apa512/clj-rethinkdb/blob/master/"
88
:src-linenum-anchor-prefix "L"}
99
:global-vars {*warn-on-reflection* true}
10-
:plugins [[codox "0.9.4"]]
10+
:plugins [[lein-codox "0.9.5"]]
1111
:dependencies [[org.clojure/clojure "1.7.0"]
1212
[org.clojure/clojurescript "1.7.48" :scope "provided"]
1313
[org.clojure/core.async "0.2.374"]

test/rethinkdb/core_test.clj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,18 @@
207207
(deftest aggregation
208208
(with-open [conn (r/connect)]
209209
(are [term result] (= (r/run term conn) result)
210+
(r/group [1 6 1 8] (r/fn [e] e)) {1 [1 1], 6 [6], 8 [8]}
211+
(r/ungroup (r/group [1 6 1 8] (r/fn [e] e))) [{:group 1, :reduction [1 1]}
212+
{:group 6, :reduction [6]}
213+
{:group 8, :reduction [8]}]
214+
(r/count [1 6 1 8]) 4
215+
(r/count "asdf") 4
216+
(r/count {:a 1 :b 2 :c 3}) 3
217+
(r/sum [3 4]) 7
210218
(r/avg [2 4]) 3
211219
(r/min [4 2]) 2
212220
(r/max [4 6]) 6
213-
(r/sum [3 4]) 7
221+
(r/distinct [1 6 1 8]) [1 6 8]
214222
(r/contains [1 6 1 8] 1) true
215223
(r/contains [1 6 1 8] 2) false)))
216224

@@ -375,6 +383,7 @@
375383
(are [term result] (= result (r/run term conn))
376384
(r/branch true 1 0) 1
377385
(r/branch false 1 0) 0
386+
(r/limit (r/range) 4) [0 1 2 3]
378387
(r/range 5) [0 1 2 3 4]
379388
(r/range 3 5) [3 4]
380389
(r/coerce-to [["name" "Pikachu"]] "OBJECT") {:name "Pikachu"}

0 commit comments

Comments
 (0)