Permalink
Browse files

did the queue flushing and upped the version number

  • Loading branch information...
1 parent c14e118 commit d6694120710cea434c8519840f95b4f78f919672 @adamwynne committed Aug 3, 2011
Showing with 35 additions and 13 deletions.
  1. +3 −2 project.clj
  2. +2 −3 src/kestrel/client.clj
  3. +30 −8 test/kestrel/test/client.clj
View
@@ -1,7 +1,8 @@
-(defproject kestrel-client "0.1.0-SNAPSHOT"
+(defproject kestrel-client/kestrel-client "0.1.0"
:description "client for kestrel via the memcached interface"
:repositories {"spy" "http://files.couchbase.com/maven2/"}
- :dev-dependencies [[swank-clojure "1.3.2"]]
+ :dev-dependencies [[swank-clojure "1.3.2"]
+ [lein-clojars "0.6.0"]]
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.2.0"]
[spy/spymemcached "2.7"]])
View
@@ -29,7 +29,7 @@
"Adds an item to a specific queue"
[queue-name data & {:keys [timeout] :or {timeout 0}}]
- (.set (default-client) queue-name timeout data))
+ (.set (default-client) queue-name timeout (str data)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -64,8 +64,7 @@
"drops items in a queue, leaving it empty"
[queue-name]
- ;FIXME: do the goods
- )
+ (while (get-item queue-name)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -5,10 +5,30 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defmacro with-queue
+ [queue-name & body]
+
+ `(do (delete-queue ~queue-name)
+ ~@body
+ (delete-queue ~queue-name)))
+
(deftest test-create-client
(is (= (type (#'kestrel.client/create-client))
net.spy.memcached.MemcachedClient)))
+(deftest test-delete
+ (let [q-name "testq"
+ q-val "test value"]
+ (set-item q-name q-val)
+ (delete-queue q-name)
+ (is (nil? (get-item q-name)))))
+
+(deftest test-queue
+ (let [q-name "testq"]
+ (with-queue q-name
+ (doseq [i (range 10)] (set-item q-name i))
+ (is (= (range 10) (repeatedly 10 #(java.lang.Integer/parseInt (get-item q-name))))))))
+
(deftest test-queue-name
(is (= (#'kestrel.client/decorate-queue-name "myname" nil nil nil) "myname"))
(is (= (#'kestrel.client/decorate-queue-name "myname" 0 nil nil) "myname/t=0"))
@@ -18,18 +38,20 @@
(is (= (#'kestrel.client/decorate-queue-name "myname" nil :close nil) "myname/close"))
(is (= (#'kestrel.client/decorate-queue-name "myname" 1000 :abort nil) "myname/t=1000/abort")))
-(deftest test-delete
- (let [q-name "testq"
- q-val "test value"]
- (set-item q-name q-val)
- (delete-queue q-name)
- (is (nil? (get-item q-name)))))
+(deftest test-flush-queue
+ (let [q-name "testq"]
+ (with-queue q-name
+ (set-item q-name 1)
+ (set-item q-name 2)
+ (flush-queue q-name)
+ (is (nil? (get-item q-name))))))
(deftest test-set-get
(let [q-name "testq"
q-val "test value"]
- (set-item q-name q-val)
- (is (= (get-item q-name) q-val))))
+ (with-queue q-name
+ (set-item q-name q-val)
+ (is (= (get-item q-name) q-val)))))
(deftest test-version
(let [v (get-version)]

0 comments on commit d669412

Please sign in to comment.