-
Notifications
You must be signed in to change notification settings - Fork 2
/
clj_http_test.clj
26 lines (21 loc) · 1.07 KB
/
clj_http_test.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(ns unit.parenthesin.components.http.clj-http-test
(:require [clojure.test :refer [deftest is testing]]
[com.stuartsierra.component :as component]
[matcher-combinators.test :refer [match?]]
[parenthesin.components.http.clj-http :as http.clj-http]))
(defn- create-and-start-system!
[{:keys [http]}]
(component/start-system
(component/system-map :http http)))
(deftest http-mock-component-test
(testing "HttpMock should return mocked reponses and log requests in the atom"
(let [system (create-and-start-system!
{:http (http.clj-http/new-http-mock
{"https://duckduckgo.com" {:status 200}})})]
(is (match? {:status 200}
(http.clj-http/request (:http system) {:url "https://duckduckgo.com"})))
(is (match? {:status 500}
(http.clj-http/request (:http system) {:url "https://google.com"})))
(is (match? ["https://duckduckgo.com"
"https://google.com"]
(map :url (deref (get-in system [:http :requests]))))))))