Skip to content

Commit

Permalink
Merge pull request #152 from anthonygalea/master
Browse files Browse the repository at this point in the history
Add tests for group, ungroup, count, distinct. Relates to #117.
  • Loading branch information
danielcompton committed May 4, 2016
2 parents dc4b491 + a6e066e commit b58b1c8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. This change
## [Unreleased]
### Changed
- Renamed indexes-of to offsets-of.

### Added
- Added range.

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:src-dir-uri "https://github.com/apa512/clj-rethinkdb/blob/master/"
:src-linenum-anchor-prefix "L"}
:global-vars {*warn-on-reflection* true}
:plugins [[codox "0.9.4"]]
:plugins [[lein-codox "0.9.5"]]
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.48" :scope "provided"]
[org.clojure/core.async "0.2.374"]
Expand Down
11 changes: 10 additions & 1 deletion test/rethinkdb/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,18 @@
(deftest aggregation
(with-open [conn (r/connect)]
(are [term result] (= (r/run term conn) result)
(r/group [1 6 1 8] (r/fn [e] e)) {1 [1 1], 6 [6], 8 [8]}
(r/ungroup (r/group [1 6 1 8] (r/fn [e] e))) [{:group 1, :reduction [1 1]}
{:group 6, :reduction [6]}
{:group 8, :reduction [8]}]
(r/count [1 6 1 8]) 4
(r/count "asdf") 4
(r/count {:a 1 :b 2 :c 3}) 3
(r/sum [3 4]) 7
(r/avg [2 4]) 3
(r/min [4 2]) 2
(r/max [4 6]) 6
(r/sum [3 4]) 7
(r/distinct [1 6 1 8]) [1 6 8]
(r/contains [1 6 1 8] 1) true
(r/contains [1 6 1 8] 2) false)))

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

0 comments on commit b58b1c8

Please sign in to comment.