Skip to content

Commit

Permalink
Fixed failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
gcv committed Oct 13, 2009
1 parent 3507971 commit 9cad0ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/cupboard/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@
opts (merge defaults (args-map opts-args))
cb (opts :cupboard)
txn (opts :txn)]
(when-not (= (close-shelf cb shelf-name :remove true :txn txn)
OperationStatus/SUCCESS)
(throw (RuntimeException. "failed to remove shelf " shelf-name)))))
(close-shelf cb shelf-name :remove true :txn txn)))


(defn list-shelves [& opts-args]
Expand Down
14 changes: 8 additions & 6 deletions src/test/cupboard/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,23 @@
(.start (Thread. (fn []
(with-txn [:cupboard cb :max-attempts 2 :retry-delay-msec 10]
(passoc! gw :bank-acct 1 :cupboard cb)
(Thread/sleep 5)
(Thread/sleep 50)
(passoc! ja :bank-acct 2 :cupboard cb))
(reset! done-1 true))))
(.start (Thread. (fn []
(with-txn [:cupboard cb :max-attempts 2 :retry-delay-msec 50]
(with-txn [:cupboard cb :max-attempts 2 :retry-delay-msec 250]
(passoc! ja :bank-acct 3 :cupboard cb)
(Thread/sleep 5)
(Thread/sleep 50)
(passoc! gw :bank-acct 4 :cupboard cb))
(reset! done-2 true))))
;; wait for threads to complete
(loop [i 0]
(when-not (and @done-1 @done-2)
(Thread/sleep 100)
(recur (inc i))))
;; The first thread has a shorter retry delay, so it should win the race.
;; The first thread has a shorter retry delay, so it should win the
;; race. It commits first, then the second thread overwrites the
;; values.
(is (= (retrieve :login "gw" :cupboard cb) (assoc gw :bank-acct 4)))
(is (= (retrieve :login "ja" :cupboard cb) (assoc ja :bank-acct 3))))

Expand Down Expand Up @@ -442,8 +444,8 @@

(testing "making sure natural joins are used wherever possible"
(let [q (macroexpand-1
'(query (= :age 58) (= :last-name "Adams")
:callback #(passoc! % :first-name "John Quincy")))]
'(cupboard.core/query (= :age 58) (= :last-name "Adams")
:callback #(passoc! % :first-name "John Quincy")))]
(is (= (first (first (rest (rest (rest (first (rest q)))))))
'cupboard.core/query-natural-join)))
(query (= :age 58) (= :last-name "Adams")
Expand Down

0 comments on commit 9cad0ff

Please sign in to comment.