Prepare btcdata for Kubernetes deployment

This commit is contained in:
2026-09-17 11:19:04 +02:00
parent fb334c7703
commit 382da4351a
8 changed files with 394 additions and 3 deletions
@@ -0,0 +1,26 @@
(ns pmagnus.btcdata.web.controllers.health-test
(:require
[clojure.test :refer [deftest is testing]]
[pmagnus.btcdata.web.controllers.health :as health]))
(deftest healthcheck-is-process-only
(let [response (health/healthcheck! {})]
(is (= 200 (:status response)))
(is (= "up" (get-in response [:body :app :status])))))
(deftest readiness-check-tests-database
(testing "ready when the database query succeeds"
(let [called (atom nil)
query-fn (fn [query params]
(reset! called [query params])
{:healthy 1})
response (health/readiness-check! query-fn {})]
(is (= 200 (:status response)))
(is (= {:status "ready"} (:body response)))
(is (= [:check-database {}] @called))))
(testing "not ready when the database query fails"
(let [query-fn (fn [_ _] (throw (ex-info "database unavailable" {})))
response (health/readiness-check! query-fn {})]
(is (= 503 (:status response)))
(is (= {:status "not ready"} (:body response))))))