babashka/test-resources/lib_tests/clj_http/lite/client_test.clj
Gabriel Horner 665ae4dd97
Finish up library tests (#1120)
* Add tests for markdown-clj and tools.namespace

See comment for why only one markdown test could be run.
Closes #1069 and #1064

* Convert 10 test libs using add-libtest

Also improved add-libtest to only require maven artifact
and rely on clojars for getting git-url most of the time

* Convert 8 more test libs using add-libtest

Also updated table and added comment for newline test

* Fix doric test

* Disable tools.namespace test that fails on windows

* Added dozen manual test libs and converted 2 test libs

add-libtest.clj supports manually-added and test-directories options

* Converts last tests to test namespaces and write libraries.csv

* Add a number of library tests from projects.md

Also add more docs around adding test libs and tweak add script

* Use :sha for gitlib and older clojure cli

* Revert "Use :sha for gitlib and older clojure cli"

This reverts commit c663ab8368.

* Fix and disable failing tests

Disabled tests that fail consistently and fixed windows one
2021-12-29 16:35:14 +01:00

35 lines
1.5 KiB
Clojure

(ns clj-http.lite.client-test
(:require [cheshire.core :as json]
[clj-http.lite.client :as client]
[clojure.test :as t :refer [deftest is]]))
(deftest client-test
(is (= 200 (:status (client/get "https://www.clojure.org" {:throw-exceptions false}))))
(is (= 200 (:status (client/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2" {:throw-exceptions false}))))
(is (= 200 (:status (client/post "https://postman-echo.com/post" {:throw-exceptions false}))))
(is (= 200 (:status (client/post "https://postman-echo.com/post"
{:body (json/generate-string {:a 1})
:headers {"X-Hasura-Role" "admin"}
:content-type :json
:accept :json
:throw-exceptions false}))))
(is (= 200 (:status (client/put "https://postman-echo.com/put"
{:body (json/generate-string {:a 1})
:headers {"X-Hasura-Role" "admin"}
:content-type :json
:accept :json
:throw-exceptions false})))))
(deftest exception-test
(try (client/get "https://site.com/broken")
(is false "should not reach here")
(catch Exception e
(is (:headers (ex-data e))))))
;; BB-TEST-PATCH: Added test
(deftest insecure-test
(is (= 200 (:status (client/get "https://self-signed.badssl.com/" {:insecure? true})))))