From 572ddb9747522ecff870aa28aaac167fc9e88be9 Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 7 Jun 2023 12:16:15 +0200 Subject: [PATCH] Update tests --- .../cljc/dda/c4k_forgejo/forgejo_test.cljc | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc index ef03fa6..a068e00 100644 --- a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc +++ b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc @@ -7,6 +7,7 @@ [dda.c4k-common.base64 :as b64] [dda.c4k-forgejo.forgejo :as cut])) +(st/instrument `cut/generate-deployment) (st/instrument `cut/generate-appini-env) (st/instrument `cut/generate-ingress) (st/instrument `cut/generate-secrets) @@ -14,6 +15,8 @@ (deftest should-generate-appini-env (is (= {:APP_NAME-c1 "", :APP_NAME-c2 "test forgejo", + :FORGEJO__federation__ENABLED-c1 "false", + :FORGEJO__federation__ENABLED-c2 "true", :FORGEJO__mailer__FROM-c1 "", :FORGEJO__mailer__FROM-c2 "test@test.com", :FORGEJO__mailer__SMTP_ADDR-c1 "m.t.de", @@ -31,6 +34,7 @@ :FORGEJO__service__NO_REPLY_ADDRESS-c1 "", :FORGEJO__service__NO_REPLY_ADDRESS-c2 "noreply@test.com"} (th/map-diff (cut/generate-appini-env {:default-app-name "" + :deploy-federated "false" :fqdn "test.de" :mailer-from "" :mailer-host "m.t.de" @@ -39,6 +43,7 @@ :service-noreply-address "" }) (cut/generate-appini-env {:default-app-name "test forgejo" + :deploy-federated "true" :fqdn "test.com" :mailer-from "test@test.com" :mailer-host "mail.test.com" @@ -47,6 +52,63 @@ :service-noreply-address "noreply@test.com" }))))) +(deftest should-generate-non-federated-deployment + (is (= {:apiVersion "apps/v1", + :kind "Deployment", + :metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}}, + :spec + {:replicas 1, + :selector {:matchLabels {:app "forgejo"}}, + :template + {:metadata {:name "forgejo", :labels {:app "forgejo"}}, + :spec + {:containers + [{:name "forgejo", + :image "codeberg.org/forgejo/forgejo:1.19", + :imagePullPolicy "IfNotPresent", + :envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}], + :volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}], + :ports [{:containerPort 22, :name "git-ssh"} {:containerPort 3000, :name "forgejo"}]}], + :volumes [{:name "forgejo-data-volume", :persistentVolumeClaim {:claimName "forgejo-data-pvc"}}]}}}} + (cut/generate-deployment + {:default-app-name "" + :deploy-federated "false" + :fqdn "test.de" + :mailer-from "" + :mailer-host "m.t.de" + :mailer-port "123" + :service-domain-whitelist "adb.de" + :service-noreply-address ""} + )))) + +(deftest should-generate-federated-deployment + (is (= {:apiVersion "apps/v1", + :kind "Deployment", + :metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}}, + :spec + {:replicas 1, + :selector {:matchLabels {:app "forgejo"}}, + :template + {:metadata {:name "forgejo", :labels {:app "forgejo"}}, + :spec + {:containers + [{:name "forgejo", + :image "codeberg.org/meissa/forgejo:federated-latest", + :imagePullPolicy "IfNotPresent", + :envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}], + :volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}], + :ports [{:containerPort 22, :name "git-ssh"} {:containerPort 3000, :name "forgejo"}]}], + :volumes [{:name "forgejo-data-volume", :persistentVolumeClaim {:claimName "forgejo-data-pvc"}}]}}}} + (cut/generate-deployment + {:default-app-name "" + :deploy-federated "true" + :fqdn "test.de" + :mailer-from "" + :mailer-host "m.t.de" + :mailer-port "123" + :service-domain-whitelist "adb.de" + :service-noreply-address ""})))) + (deftest should-generate-secret (is (= {:FORGEJO__database__USER-c1 "", :FORGEJO__database__USER-c2 (b64/encode "pg-user"),