Added shynet webserver unit test

This commit is contained in:
Clemens Geibel 2022-01-21 14:26:46 +01:00
parent 33e394f0a2
commit 194b87467c
3 changed files with 59 additions and 6 deletions

25
.gitignore vendored
View file

@ -1,3 +1,28 @@
.clj-kondo/
.lsp/
# pybuilder
.pybuilder/
__pycache__/
# lein
target/
.lein-repl-history
.lein-failures
pom.*
# cljs
.shadow-cljs
.nrepl-*
package-lock.json
node_modules/
public/js/
# ide
.calva
*.iml
.idea/
auth.edn
config.edn

View file

@ -13,10 +13,10 @@
(defmethod yaml/load-resource :matomo [resource-name]
(case resource-name
"matomo/certificate.yaml" (rc/inline "matomo/certificate.yaml")
"matomo/deployments.yaml" (rc/inline "matomo/deployments.yaml")
"matomo/ingress.yaml" (rc/inline "matomo/ingress.yaml")
"matomo/services.yaml" (rc/inline "matomo/services.yaml")
"matomo/statefulset.yaml" (rc/inline "matomo/statefulset.yaml")
;"matomo/deployments.yaml" (rc/inline "matomo/deployments.yaml")
;"matomo/ingress.yaml" (rc/inline "matomo/ingress.yaml")
;"matomo/services.yaml" (rc/inline "matomo/services.yaml")
;"matomo/statefulset.yaml" (rc/inline "matomo/statefulset.yaml")
(throw (js/Error. "Undefined Resource!")))))
(defn generate-certificate [config]
@ -31,8 +31,8 @@
(defn generate-webserver-deployment []
(let [shynet-application "shynet-webserver"]
(-> (yaml/from-string (yaml/load-resource "matomo/deployments-template.yaml"))
(cm/replace-named-value "shynet-application" shynet-application)
(dissoc [:spec :template :spec :containers 0] :command))))
(cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application)
(update-in [:spec :template :spec :containers 0] dissoc :command))))
(defn generate-ingress [config]
(let [{:keys [fqdn issuer]

View file

@ -0,0 +1,28 @@
(ns dda.c4k-matomo.matomo-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-matomo.matomo :as cut]))
(deftest should-generate-webserver-deployment
(is (= {:apiVersion "apps/v1"
:kind "Deployment"
:metadata
{:name "shynet-webserver"
:namespace "default"
:labels {:app "shynet-webserver"}}
:spec
{:selector {:matchLabels {:app "shynet-webserver"}}
:strategy {:type "Recreate"}
:replicas 1
:template
{:metadata {:labels {:app "shynet-webserver"}}
:spec
{:containers
[{:name "shynet-webserver"
:image "milesmcc/shynet:edge"
:imagePullPolicy "IfNotPresent"
:envFrom [{:secretRef {:name "shynet-settings"}}]}]}}}}
(cut/generate-webserver-deployment))))