|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
|
|
|
|
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
|
|
|
|
[clojure.spec.test.alpha :as st]
|
|
|
|
|
[dda.c4k-common.common-test :as ct]
|
|
|
|
|
[dda.c4k-common.postgres :as cut]))
|
|
|
|
|
|
|
|
|
|
(st/instrument `cut/generate-config)
|
|
|
|
@ -27,6 +28,13 @@
|
|
|
|
|
(:data (cut/generate-config {:db-name "test"}))))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(deftest should-generate-config-diff
|
|
|
|
|
(is (= {:postgres-db-c1 "postgres",
|
|
|
|
|
:postgres-db-c2 "test",
|
|
|
|
|
:postgresql.conf-c1 "max_connections = 100\nwork_mem = 4MB\nshared_buffers = 512MB\n",
|
|
|
|
|
:postgresql.conf-c2 "max_connections = 700\nwork_mem = 3MB\nshared_buffers = 2048MB\n"}
|
|
|
|
|
(ct/map-diff (cut/generate-config) (cut/generate-config {:db-name "test" :postgres-size :8gb})))))
|
|
|
|
|
|
|
|
|
|
(deftest should-generate-persistent-volume
|
|
|
|
|
(is (= {:kind "PersistentVolume"
|
|
|
|
|
:apiVersion "v1"
|
|
|
|
@ -50,6 +58,13 @@
|
|
|
|
|
(cut/generate-persistent-volume {:postgres-data-volume-path "xx"
|
|
|
|
|
:pv-storage-size-gb 20}))))
|
|
|
|
|
|
|
|
|
|
(deftest should-generate-persistent-volume-diff
|
|
|
|
|
(is (= {:storage-c1 "10Gi", :storage-c2 "20Gi",
|
|
|
|
|
:path-c1 "/var/postgres", :path-c2 "xx"}
|
|
|
|
|
(ct/map-diff (cut/generate-persistent-volume {})
|
|
|
|
|
(cut/generate-persistent-volume {:postgres-data-volume-path "xx"
|
|
|
|
|
:pv-storage-size-gb 20})))))
|
|
|
|
|
|
|
|
|
|
(deftest should-generate-persistent-volume-claim
|
|
|
|
|
(is (= {:apiVersion "v1"
|
|
|
|
|
:kind "PersistentVolumeClaim"
|
|
|
|
@ -71,6 +86,13 @@
|
|
|
|
|
(cut/generate-pvc {:pv-storage-size-gb 20
|
|
|
|
|
:pvc-storage-class-name :local-path}))))
|
|
|
|
|
|
|
|
|
|
(deftest should-generate-persistent-volume-claim-diff
|
|
|
|
|
(is (= {:storageClassName-c1 "manual", :storageClassName-c2 "local-path",
|
|
|
|
|
:storage-c1 "10Gi", :storage-c2 "20Gi"}
|
|
|
|
|
(ct/map-diff (cut/generate-pvc {})
|
|
|
|
|
(cut/generate-pvc {:pv-storage-size-gb 20
|
|
|
|
|
:pvc-storage-class-name :local-path})))))
|
|
|
|
|
|
|
|
|
|
(deftest should-generate-secret
|
|
|
|
|
(is (= {:apiVersion "v1"
|
|
|
|
|
:kind "Secret"
|
|
|
|
@ -106,3 +128,7 @@
|
|
|
|
|
:mountPath "/var/lib/postgresql/data"}]}]
|
|
|
|
|
(get-in (cut/generate-deployment {:postgres-image "postgres:14"})
|
|
|
|
|
[:spec :template :spec :containers]))))
|
|
|
|
|
|
|
|
|
|
(deftest should-generate-deployment-diff
|
|
|
|
|
(is (= {:image-c1 "postgres:13", :image-c2 "postgres:14"}
|
|
|
|
|
(ct/map-diff (cut/generate-deployment) (cut/generate-deployment {:postgres-image "postgres:14"})))))
|