mop add test

This commit is contained in:
ansgarz 2022-03-18 12:33:07 +01:00
parent 1c179daf2c
commit 7453c4edd9
3 changed files with 16 additions and 4 deletions

View file

@ -5,7 +5,8 @@
[clojure.string :as cs] [clojure.string :as cs]
[clojure.tools.reader.edn :as edn] [clojure.tools.reader.edn :as edn]
[expound.alpha :as expound] [expound.alpha :as expound]
[dda.c4k-nextcloud.core :as core])) [dda.c4k-nextcloud.core :as core]
[dda.c4k-nextcloud.nextcloud :as nextcloud]))
(def usage (def usage
"usage: "usage:
@ -22,7 +23,7 @@
(defn expound-config (defn expound-config
[config] [config]
(expound/expound ::core/config config)) (expound/expound ::nextcloud/config config))
(defn invalid-args-msg (defn invalid-args-msg
[spec args] [spec args]
@ -43,14 +44,14 @@
auth-str (slurp auth) auth-str (slurp auth)
config-edn (edn/read-string config-str) config-edn (edn/read-string config-str)
auth-edn (edn/read-string auth-str) auth-edn (edn/read-string auth-str)
config-valid? (s/valid? core/config? config-edn) config-valid? (s/valid? nextcloud/config? config-edn)
auth-valid? (s/valid? core/auth? auth-edn)] auth-valid? (s/valid? core/auth? auth-edn)]
(if (and config-valid? auth-valid?) (if (and config-valid? auth-valid?)
(println (core/generate config-edn auth-edn)) (println (core/generate config-edn auth-edn))
(do (do
(when (not config-valid?) (when (not config-valid?)
(println (println
(expound/expound-str core/config? config-edn {:print-specs? false}))) (expound/expound-str nextcloud/config? config-edn {:print-specs? false})))
(when (not auth-valid?) (when (not auth-valid?)
(println (println
(expound/expound-str core/auth? auth-edn {:print-specs? false}))))))))))) (expound/expound-str core/auth? auth-edn {:print-specs? false})))))))))))

View file

@ -2,6 +2,8 @@
(:require (:require
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
#?(:cljs [shadow.resource :as rc]) #?(:cljs [shadow.resource :as rc])
#?(:clj [orchestra.core :refer [defn-spec]]
:cljs [orchestra.core :refer-macros [defn-spec]])
[dda.c4k-common.yaml :as yaml] [dda.c4k-common.yaml :as yaml]
[dda.c4k-common.base64 :as b64] [dda.c4k-common.base64 :as b64]
[dda.c4k-common.predicate :as cp] [dda.c4k-common.predicate :as cp]

View file

@ -66,6 +66,15 @@
:hostPath {:path "xx"}}} :hostPath {:path "xx"}}}
(cut/generate-persistent-volume {:nextcloud-data-volume-path "xx"})))) (cut/generate-persistent-volume {:nextcloud-data-volume-path "xx"}))))
(deftest should-generate-persistent-volume-claim
(is (= {([:apiVersion "v1"]
[:kind "PersistentVolumeClaim"]
[:metadata #ordered/map
([:name "cloud-pvc"]
[:labels #ordered/map
([:app.kubernetes.io/application "cloud"])])] [:spec #ordered/map ([:storageClassName "manual"] [:accessModes ["ReadWriteOnce"]] [:resources #ordered/map ([:requests #ordered/map ([:storage "50Gi"])])] [:selector #ordered/map ([:matchLabels #ordered/map ([:app.kubernetes.io/application "cloud"])])])])}
(cut/generate-pvc {:nextcloud-data-volume-path "xx"}))))
(deftest should-generate-deployment (deftest should-generate-deployment
(is (= {:apiVersion "apps/v1" (is (= {:apiVersion "apps/v1"
:kind "Deployment" :kind "Deployment"