Skip to content

Commit

Permalink
added test helper so that I can mark tests as pending. Made the compo…
Browse files Browse the repository at this point in the history
…site-serializer test pending. added test for column range fetch for dynamic colums
  • Loading branch information
Matt Stump committed Dec 21, 2011
1 parent c80f94a commit 459ebf3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
41 changes: 31 additions & 10 deletions test/clj_hector/test/core.clj
Expand Up @@ -2,12 +2,12 @@
(:import [me.prettyprint.cassandra.serializers StringSerializer])
(:require [clj-hector.serialize :as s])
(:use [clojure.test]
[clj-hector.test.test-helper]
[clj-hector.test.cassandra-helper :only (with-test-keyspace)]
[clj-hector.core] :reload))

(deftest serializers
(deftest-pending composite-serializer
(let [column-family "A"]

(with-test-keyspace keyspace [{:name column-family}]
(testing ":composite serializer"
(let [opts [:v-serializer :string
Expand All @@ -20,18 +20,13 @@
:comparator :ascii})]

(put keyspace column-family "row-key" {comp "v"} :n-serializer :composite)
(printf "%s\n" (.toString comp))
(printf "%s\n" (first
(keys
(get
(first
(apply get-rows keyspace column-family ["row-key"] opts)) "row-key"))))

(is (= [{"row-key" {["col" "name"] "v"}}]
(apply get-rows keyspace column-family ["row-key"] opts))
(= {["col" "name"] "v"}
(apply get-columns keyspace column-family "row-key" [comp] opts))))))
(apply get-columns keyspace column-family "row-key" [comp] opts))))))))

(deftest serializers
(let [column-family "A"]
(with-test-keyspace keyspace [{:name column-family}]
(testing ":dynamic-composite serializer"
(let [opts [:v-serializer :string
Expand Down Expand Up @@ -108,6 +103,32 @@
"c" "v"}
(apply get-column-range keyspace column-family "row-key" "a" "c" opts))))))

(deftest dynamic-composite-column-ranges
(with-test-keyspace keyspace [{:name "A"}]
(let [column-family "A"
opts [:v-serializer :string
:n-serializer :dynamic-composite]]

(let [cols (into {}
(interleave
(doseq [i (range 0 3)]
(create-dynamic-composite {:value "col"
:n-serializer :string
:comparator :utf-8}
{:value i
:n-serializer :integer
:comparator :integer}))
(cycle "v")))]
(put keyspace column-family "row-key" cols)
(is (= cols
(apply get-column-range
keyspace
column-family
"row-key"
(first (keys cols))
(last (keys cols))
opts)))))))

;; count-columns is different to counter columns, it's not
;; an O(1) operation.
(deftest counting-with-count-columns
Expand Down
11 changes: 11 additions & 0 deletions test/clj_hector/test/test_helper.clj
@@ -0,0 +1,11 @@
(ns clj-hector.test.test-helper
(:use [clojure.test]))

;; A Simple macro that enable to mark your test
;; to pending
;; Taken from: http://techbehindtech.com/2010/06/01/marking-tests-as-pending-in-clojure/
(defmacro deftest-pending
[name & body]
(let [message (str "\n========\n" name " is pending !!\n========\n")]
`(deftest ~name
(println ~message))))

0 comments on commit 459ebf3

Please sign in to comment.