babashka/script/lib_tests/babashka_curl_test

34 lines
993 B
Text
Raw Normal View History

2020-03-02 12:18:11 +00:00
#!/usr/bin/env bash
set -eo pipefail
2020-04-10 21:39:04 +00:00
export BABASHKA_CLASSPATH=$(clojure -Sdeps '{:deps {babasha.curl {:local/root "babashka.curl"}}}' -Spath)
2020-03-02 12:18:11 +00:00
if [ "$BABASHKA_TEST_ENV" = "native" ]; then
BB_CMD="./bb"
else
BB_CMD="lein bb"
fi
$BB_CMD -e "
2020-04-04 10:39:07 +00:00
(require '[babashka.curl :as curl] :reload-all)
2020-03-02 12:18:11 +00:00
2020-04-04 10:39:07 +00:00
(prn (:status (curl/get \"https://www.clojure.org\")))
2020-03-02 12:18:11 +00:00
2020-04-04 10:39:07 +00:00
(prn (:status (curl/get \"https://postman-echo.com/get?foo1=bar1&foo2=bar2\")))
2020-03-02 12:18:11 +00:00
2020-04-04 10:39:07 +00:00
(prn (:status (curl/post \"https://postman-echo.com/post\")))
2020-03-02 12:18:11 +00:00
2020-04-04 10:39:07 +00:00
(prn (:status (curl/post \"https://postman-echo.com/post\"
{:body (json/generate-string {:a 1})
2020-03-02 12:18:11 +00:00
:headers {\"X-Hasura-Role\" \"admin\"}
:content-type :json
2020-04-04 10:39:07 +00:00
:accept :json})))
2020-03-02 12:18:11 +00:00
2020-04-04 10:39:07 +00:00
(prn (:status (curl/put \"https://postman-echo.com/put\"
2020-03-02 12:18:11 +00:00
{:body (json/generate-string {:a 1})
:headers {\"X-Hasura-Role\" \"admin\"}
:content-type :json
2020-04-04 10:39:07 +00:00
:accept :json})))
2020-03-02 12:18:11 +00:00
"