|
47 | 47 | (with-fake-http [{} {:error cause :status nil}]
|
48 | 48 | (let [e (try (sut/request client {}) (catch Exception e e))]
|
49 | 49 | (is (re-matches #"(?i)Request to GitHub failed" (.getMessage e)))
|
50 |
| - (is (= cause (.getCause e))))))))) |
| 50 | + (is (= cause (.getCause e))))))) |
| 51 | + (testing "request headers" |
| 52 | + (testing "Can use custom headers" |
| 53 | + (with-fake-http [(fn [req] |
| 54 | + (is (= "test" (get-in req [:headers "Test-Header"])))) |
| 55 | + {:status 200}] |
| 56 | + ;; assertion is in fake http callback |
| 57 | + (sut/request client {:headers {"Test-Header" "test"}}))) |
| 58 | + (testing "Can override authentication" |
| 59 | + ;; clj-github sets authorization header unless specified. Beware that the |
| 60 | + ;; implementation here is case sensitive whereas HTTP headers are not. |
| 61 | + (with-fake-http [(fn [req] |
| 62 | + (is (= "Test SomeValue" (get-in req [:headers "Authorization"])))) |
| 63 | + {:status 200}] |
| 64 | + ;; assertion is in fake http callback |
| 65 | + (sut/request client {:headers {"Authorization" "Test SomeValue"}}))) |
| 66 | + (testing "Can override content-type" |
| 67 | + ;; clj-github sets the content-type header unless specified. Beware that the |
| 68 | + ;; implementation here is case sensitive whereas HTTP headers are not. |
| 69 | + (with-fake-http [(fn [req] |
| 70 | + (is (= "test/test" (get-in req [:headers "Content-Type"])))) |
| 71 | + {:status 200}] |
| 72 | + ;; assertion is in fake http callback |
| 73 | + (sut/request client {:headers {"Content-Type" "test/test"}})))))) |
| 74 | + |
0 commit comments