add some tests
This commit is contained in:
parent
2fc6a177ad
commit
f76a254b04
5 changed files with 47 additions and 34 deletions
|
@ -14,39 +14,31 @@
|
|||
:opt-un [::jira/issuer ::jira/jira-data-volume-path
|
||||
::postgres/postgres-data-volume-path]))
|
||||
|
||||
(def auth? (s/keys :req-un [::postgres/db-user-name ::postgres/db-user-password]))
|
||||
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password]))
|
||||
|
||||
(defn k8s-objects [config]
|
||||
(into
|
||||
[]
|
||||
(concat [(yaml/to-string (postgres/generate-config))
|
||||
(yaml/to-string (postgres/generate-secret config))]
|
||||
(when (contains? config :postgres-data-volume-path)
|
||||
[(yaml/to-string (postgres/generate-persistent-volume config))])
|
||||
[(yaml/to-string (postgres/generate-pvc))
|
||||
(yaml/to-string (postgres/generate-deployment))
|
||||
(yaml/to-string (postgres/generate-service))]
|
||||
(when (contains? config :jira-data-volume-path)
|
||||
[(yaml/to-string (jira/generate-persistent-volume config))])
|
||||
[(yaml/to-string (jira/generate-pvc))
|
||||
(yaml/to-string (jira/generate-pod config))
|
||||
(yaml/to-string (jira/generate-service))
|
||||
(yaml/to-string (jira/generate-certificate config))
|
||||
(yaml/to-string (jira/generate-ingress config))
|
||||
(yaml/to-string (jira/generate-service))])))
|
||||
|
||||
(defn-spec generate any?
|
||||
[my-config config?
|
||||
my-auth auth?]
|
||||
(let [resulting-config (merge config-defaults my-config my-auth)]
|
||||
(cs/join
|
||||
"\n"
|
||||
(into
|
||||
[(yaml/to-string (postgres/generate-config))
|
||||
"---"
|
||||
(yaml/to-string (postgres/generate-secret resulting-config))]
|
||||
(when-some [{:keys [postgres-data-volume-path]} resulting-config]
|
||||
["---"
|
||||
(yaml/to-string (postgres/generate-persistent-volume resulting-config))])
|
||||
["---"
|
||||
(yaml/to-string (postgres/generate-pvc))
|
||||
"---"
|
||||
(yaml/to-string (postgres/generate-deployment))
|
||||
"---"
|
||||
(yaml/to-string (postgres/generate-service))]
|
||||
(when-some [{:keys [jira-data-volume-path]} resulting-config]
|
||||
["---"
|
||||
(yaml/to-string (jira/generate-persistent-volume resulting-config))])
|
||||
["---"
|
||||
(yaml/to-string (jira/generate-pvc))
|
||||
"---"
|
||||
(yaml/to-string (jira/generate-pod resulting-config))
|
||||
"---"
|
||||
(yaml/to-string (jira/generate-service))
|
||||
"---"
|
||||
(yaml/to-string (jira/generate-certificate resulting-config))
|
||||
"---"
|
||||
(yaml/to-string (jira/generate-ingress resulting-config))
|
||||
"---"
|
||||
(yaml/to-string (jira/generate-service))]))))
|
||||
"\n---\n"
|
||||
(k8s-objects resulting-config))))
|
||||
|
|
|
@ -46,6 +46,6 @@ spec:
|
|||
- name: postgres-config-volume
|
||||
configMap:
|
||||
name: postgres-config
|
||||
- name: postgre-d
|
||||
- name: postgre-data-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: postgres-claim
|
||||
|
|
19
src/test/cljc/dda/c4k_jira/core_test.cljc
Normal file
19
src/test/cljc/dda/c4k_jira/core_test.cljc
Normal file
|
@ -0,0 +1,19 @@
|
|||
(ns dda.c4k-jira.core-test
|
||||
(:require
|
||||
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
||||
[dda.c4k-jira.core :as cut]))
|
||||
|
||||
(deftest should-k8s-objects
|
||||
(is (= 13
|
||||
(count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de"
|
||||
:postgres-db-user "jira"
|
||||
:postgres-db-password "jira-db-password"
|
||||
:issuer :prod
|
||||
:jira-data-volume-path "/var/jira"
|
||||
:postgres-data-volume-path "/var/postgres"}))))
|
||||
(is (= 11
|
||||
(count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de"
|
||||
:postgres-db-user "jira"
|
||||
:postgres-db-password "jira-db-password"
|
||||
:issuer :prod})))))
|
|
@ -1,2 +1,2 @@
|
|||
{:db-user-name "jira"
|
||||
:db-user-password "jira-db-password"}
|
||||
{:postgres-db-user "jira"
|
||||
:postgres-db-password "jira-db-password"}
|
|
@ -1 +1,3 @@
|
|||
{:fqdn "jira-neu.prod.meissa-gmbh.de"}
|
||||
{:fqdn "jira-neu.prod.meissa-gmbh.de"
|
||||
:jira-data-volume-path "/var/jira"
|
||||
:postgres-data-volume-path "/var/postgres"}
|
Reference in a new issue