Skip to content

Commit

Permalink
Adds at-least functionality from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrobinson committed Jan 3, 2024
1 parent a90520e commit da86b25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/awaitility_clj/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[^ConditionFactory factory [option-key option-data]]
(case option-key
:at-most (.atMost factory ^Duration (tuple->duration option-data))
:at-least (.atLeast factory ^Duration (tuple->duration option-data))
:poll-interval (.pollInterval factory ^Duration (tuple->duration option-data))))

(defn- apply-options
Expand Down
14 changes: 13 additions & 1 deletion test/awaitility_clj/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@
(testing "wait-for throws ConditionTimeoutException if condition times out"
(let [start-time (System/currentTimeMillis)
end-time (+ start-time 1500)]
(is (thrown?
(is (thrown-with-msg?
ConditionTimeoutException
#"was not fulfilled within"
(wait-for
{:at-most [200 :milliseconds]}
(fn [] (>= (System/currentTimeMillis) end-time))))))))

(deftest wait-for-throws-exception-if-finished-before-at-least
(testing "wait-for throws ConditionTimeoutException if condition happens before given at-least parameter"
(let [start-time (System/currentTimeMillis)
end-time (+ start-time 100)]
(is (thrown-with-msg?
ConditionTimeoutException
#"milliseconds which is earlier than expected minimum timeout 500 milliseconds"
(wait-for
{:at-least [500 :milliseconds]}
(fn [] (>= (System/currentTimeMillis) end-time))))))))

(deftest wait-for-poll-intervals
(testing "wait-for uses default poll interval if none set"
(let [start-time (System/currentTimeMillis)
Expand Down

0 comments on commit da86b25

Please sign in to comment.