Skip to content

Commit

Permalink
Add test for stringreader
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Apr 18, 2024
1 parent 7df8f56 commit 8723c67
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions test/babashka/http_client_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,19 @@
"q=%26moo"))))))

(deftest ring-client-test
(testing "string body"
(let [resp (http/get "https://clojure.org"
{:client (fn [_req]
{:body "Hello"})})]
(is (= "Hello" (:body resp)))))
(testing "inputstring body"
(let [resp (http/get "https://clojure.org"
{:client (fn [req]
{:body (java.io.ByteArrayInputStream. (.getBytes "Hello"))
:clojure (= "https://clojure.org" (str (:uri req)))})})]
(doseq [resp [(http/get "https://clojure.org"
{:client (fn [_req]
{:body "Hello"
:clojure true})})
(http/get "https://clojure.org"
{:client (fn [req]
{:body (java.io.ByteArrayInputStream. (.getBytes "Hello"))
:clojure (= "https://clojure.org" (str (:uri req)))})})
(http/get "https://clojure.org"
{:client (fn [_req]
{:body (java.io.StringReader. "Hello")
:clojure true})})]]
(is (:clojure resp))
(is (= "Hello" (:body resp))))))

Expand Down

0 comments on commit 8723c67

Please sign in to comment.