test helper function misc changes

This commit is contained in:
Gered 2016-05-13 14:02:29 -04:00
parent 472a551606
commit f8dfde4e3a
3 changed files with 12 additions and 9 deletions

View file

@ -57,6 +57,13 @@
[] []
(Thread/sleep 500)) (Thread/sleep 500))
(defn wait-for-heartbeat-interval (defn wait-for-scheduled-interval
[secs] [secs]
; add 1 extra second just to be 100% safe
; (intervals specified to scheduled job/task timers are never _exact_)
(Thread/sleep (+ 1000 (* 1000 secs)))) (Thread/sleep (+ 1000 (* 1000 secs))))
(defn session-id-string?
[s]
(and (string? s)
(not (string/blank? s))))

View file

@ -52,8 +52,7 @@
(let [arrays (get-response-arrays (:body resp)) (let [arrays (get-response-arrays (:body resp))
[[id [c session-id host-prefix version]]] (first arrays)] [[id [c session-id host-prefix version]]] (first arrays)]
(is (= "c" c)) (is (= "c" c))
(is (and (string? session-id) (is (session-id-string? session-id))
(not (string/blank? session-id))))
(is (nil? host-prefix)) (is (nil? host-prefix))
(is (= protocol-version version)) (is (= protocol-version version))
(is (get @sessions session-id)) (is (get @sessions session-id))
@ -107,8 +106,7 @@
(let [arrays (get-response-arrays (:body new-session-response)) (let [arrays (get-response-arrays (:body new-session-response))
[[_ [c session-id _ _]]] (first arrays)] [[_ [c session-id _ _]]] (first arrays)]
(is (= "c" c)) (is (= "c" c))
(is (and (string? session-id) (is (session-id-string? session-id))
(not (string/blank? session-id))))
session-id)) session-id))
(deftest backchannel-request-test (deftest backchannel-request-test
@ -195,7 +193,7 @@
create-resp (app (->new-session-request) options) create-resp (app (->new-session-request) options)
session-id (get-session-id create-resp) session-id (get-session-id create-resp)
back-resp (app (->new-backchannel-request session-id))] back-resp (app (->new-backchannel-request session-id))]
(wait-for-heartbeat-interval (:keep-alive-interval options)) (wait-for-scheduled-interval (:keep-alive-interval options))
(let [async-resp @async-output (let [async-resp @async-output
arrays (get-response-arrays (:body async-resp))] arrays (get-response-arrays (:body async-resp))]
(is (= 200 (:status back-resp))) (is (= 200 (:status back-resp)))

View file

@ -81,9 +81,7 @@
; browserchannel's buffering proxy test is supposed to work by initially sending ; browserchannel's buffering proxy test is supposed to work by initially sending
; "11111", then waits for 2 seconds (without closing the response), then sends ; "11111", then waits for 2 seconds (without closing the response), then sends
; "2" and finally closes the response. ; "2" and finally closes the response.
; wait for 3 secs just to be safe (wait-for-scheduled-interval 2)
(println "*** WAITING 3 SECONDS FOR BUFFERING PROXY TEST RESPONSE TO FINISH ***")
(Thread/sleep 3000)
(let [async-resp @async-output] (let [async-resp @async-output]
(is (:closed? async-resp)) (is (:closed? async-resp))
(is (= "111112" (:body async-resp)))))) (is (= "111112" (:body async-resp))))))