0
我的函數接受一個map參數,其中我從中獲取存款值。目前,我可以測試場景,例如存款金額是否爲空或存款金額是否大於某個特定值等。我的API會跟蹤用戶存款的次數,並使用原子跟蹤此次數,以及何時用戶已經超過4個存款,他/她應該會收到一定的錯誤信息。我如何使用midje測試這個場景?使用蚊帳進行clojure測試
下面是我的樣本測試案例:
(facts "Mytesting"
(fact "Invalid Amount"
(let [response (httpserver/app (mock/request
:post "/deposit"
{:deposit "9"}))] ;
(:status response) => 422
(:headers response) => {"Content-Type" "application/json; charset=utf-8", "X-Content-Type-Options" "nosniff", "X-Frame-Options" "SAMEORIGIN", "X-XSS-Protection" "1; mode=block"}
(:body response) => (json/write-str {:status-code -2 :status-msg "Invalid Amount"}))))