Skip to content

Instantly share code, notes, and snippets.

@jordanrobinson
Last active January 6, 2023 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordanrobinson/32a2e5951997c1139a2ce68afb5e13bb to your computer and use it in GitHub Desktop.
Save jordanrobinson/32a2e5951997c1139a2ce68afb5e13bb to your computer and use it in GitHub Desktop.
Awaitility blog post
(defn check-reactor-is-ready
[]
(let [counter (Math/random)]
(println (str "Reading is... " counter))
(> counter 0.5)))
await().until(checkReactorIsReady())
Reading is... 0.14748365188970014
Reading is... 0.39006578072452525
Reading is... 0.11361210088909512
Reading is... 0.3491163467675231
Reading is... 0.7100413898618688
Reading is... 0.4931516769505109
Reading is... 0.9274004405826166
Reading is... 0.776093982387096
Reading is... 0.7668150587110371
org.awaitility.core.ConditionTimeoutException: Condition foo$check_reactor_is_ready was not fulfilled within 1 seconds.
:dependencies [
...
[org.awaitility/awaitility "4.2.0"]
...
]
(-> (Awaitility/await)
(.atMost 1 java.util.concurrent.TimeUnit/SECONDS)
(.until check-reactor-is-ready))
(deftest something-happens
(.until (.atMost (Awaitility/await) 1 java.util.concurrent.TimeUnit/SECONDS) check-reactor-is-ready)
(testing "Does the reactor have all the right properties?"
(is (= "working" (reactor/condition)))))
(ns example-test
(:require
[clojure.test :refer [is testing deftest]]
(:import
(org.awaitility
Awaitility))))
(deftest something-happens
(.until (Awaitility/await) check-reactor-is-ready)
(testing "Does the reactor have all the right properties?"
(is (= "working" (reactor/condition)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment