Navigation Menu

Skip to content

Commit

Permalink
Account for very slow EventSource on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrossley3 committed Feb 11, 2015
1 parent 1259de9 commit f7f6e91
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/test/immutant/web/sse_test.clj
Expand Up @@ -38,7 +38,8 @@
(event->str {:data (range 3)})))))

(deftest sse
(let [closed (promise)
(let [complete (promise)
closed (promise)
result (atom [])
app (fn [req]
(as-channel req
Expand All @@ -47,7 +48,7 @@
(send! ch x)
(Thread/sleep 10))
(send! ch {:event "close", :data "bye!"}
{:on-complete (fn [_] (swap! result conj :done))}))))
{:on-complete (fn [_] (deliver complete :success))}))))
server (run app)
client (event-source "http://localhost:8080")]
(handle-events client (fn [e]
Expand All @@ -56,10 +57,10 @@
(.close client)
(deliver closed :success))))
(.open client)
(is (= :success (deref closed 5000 :fail)))
(is (= :success (deref complete 2000 :fail)))
(is (= :success (deref closed 2000 :fail)))
(is (not (.isOpen client)))
(is (= ["5" "4" "3" "2" "1"] (take 5 @result)))
(is (= #{:done "bye!"} (set (drop 5 @result))))
(is (= ["5" "4" "3" "2" "1" "bye!"] @result))
(stop server)))

(deftest sse-should-be-utf8-and-have-proper-content-type
Expand Down

0 comments on commit f7f6e91

Please sign in to comment.