From 5f1626f488c787cf65101a7d42ed27ecf2602f37 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 25 Aug 2023 12:47:26 +0200 Subject: [PATCH] Implement generation tests --- src/test/cljc/dda/c4k_taiga/taiga_test.cljc | 100 +++++++++++++++++++- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/src/test/cljc/dda/c4k_taiga/taiga_test.cljc b/src/test/cljc/dda/c4k_taiga/taiga_test.cljc index 72cfb9e..dcb2fb5 100644 --- a/src/test/cljc/dda/c4k_taiga/taiga_test.cljc +++ b/src/test/cljc/dda/c4k_taiga/taiga_test.cljc @@ -5,8 +5,100 @@ :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) [clojure.spec.alpha :as s] [dda.c4k-common.yaml :as yaml] - [dda.c4k-taiga.core :as cut] - [clojure.spec.alpha :as s])) + [dda.c4k-taiga.taiga :as cut])) -(deftest dummy-taiga-test - (is true)) \ No newline at end of file +#?(:cljs + (defmethod yaml/load-resource :website-test [resource-name] + (case resource-name + "taiga-test/valid-config.yaml" (rc/inline "taiga-test/valid-config.yaml") + "taiga-test/valid-auth.yaml" (rc/inline "taiga-test/valid-auth.yaml") + (throw (js/Error. "Undefined Resource!"))))) + +(deftest should-generate-configmap + (is (= {:apiVersion "v1", + :kind "ConfigMap", + :metadata {:name "taiga-configmap", :namespace "default"}, + :data + {:ENABLE_TELEMETRY "false", + :TAIGA_SITES_SCHEME "https", + :TAIGA_SITES_DOMAIN "taiga.test.meissa.de", + :TAIGA_SUBPATH "", + :TAIGA_URL "https://taiga.test.meissa.de", + :TAIGA_WEBSOCKETS_URL "wss://taiga.test.meissa.de", + :PUBLIC_REGISTER_ENABLED "false", + :ENABLE_GITHUB_IMPORTER "false", + :ENABLE_JIRA_IMPORTER "false", + :ENABLE_TRELLO_IMPORTER "false", + :RABBITMQ_DEFAULT_VHOST "taiga", + :SESSION_COOKIE_SECURE "false", + :CSRF_COOKIE_SECURE "false"}} + (cut/generate-configmap (yaml/load-as-edn "taiga-test/valid-config.yaml"))))) + +(deftest should-generate-pvc-taiga-media-data + (is (= {:apiVersion "v1", + :kind "PersistentVolumeClaim", + :metadata + {:name "taiga-media-data", + :namespace "default", + :labels {:app "taiga", :app.kubernetes.part-of "taiga"}}, + :spec + {:storageClassName "local-path", + :accessModes ["ReadWriteOnce"], + :resources {:requests {:storage "5"}}}} + (cut/generate-pvc-taiga-media-data (yaml/load-as-edn "taiga-test/valid-config.yaml"))))) + +(deftest should-generate-pvc-taiga-static-data + (is (= {:apiVersion "v1", + :kind "PersistentVolumeClaim", + :metadata + {:name "taiga-media-data", + :namespace "default", + :labels {:app "taiga", :app.kubernetes.part-of "taiga"}}, + :spec + {:storageClassName "local-path", + :accessModes ["ReadWriteOnce"], + :resources {:requests {:storage "5"}}}} + (cut/generate-pvc-taiga-static-data (yaml/load-as-edn "taiga-test/valid-config.yaml"))))) + +(deftest should-generate-rabbitmq-pvc-async + (is (= {:apiVersion "v1", + :kind "PersistentVolumeClaim", + :metadata + {:name "taiga-media-data", + :namespace "default", + :labels {:app "taiga", :app.kubernetes.part-of "taiga"}}, + :spec + {:storageClassName "local-path", + :accessModes ["ReadWriteOnce"], + :resources {:requests {:storage "5"}}}} + (cut/generate-rabbitmq-pvc-async(yaml/load-as-edn "taiga-test/valid-config.yaml"))))) + +(deftest should-generate-rabbitmq-pvc-events + (is (= {:apiVersion "v1", + :kind "PersistentVolumeClaim", + :metadata + {:name "taiga-media-data", + :namespace "default", + :labels {:app "taiga", :app.kubernetes.part-of "taiga"}}, + :spec + {:storageClassName "local-path", + :accessModes ["ReadWriteOnce"], + :resources {:requests {:storage "5"}}}} + (cut/generate-rabbitmq-pvc-events (yaml/load-as-edn "taiga-test/valid-config.yaml"))))) + +(deftest should-generate-secret + (is (= {:apiVersion "v1", + :kind "Secret", + :metadata + {:name "taiga-secret", :labels {:app.kubernetes.part-of "taiga"}}, + :data + {:TAIGA_SECRET_KEY "some-key", + :EMAIL_HOST_USER "mailer-user", + :EMAIL_HOST_PASSWORD "mailer-pw", + :RABBITMQ_USER "rabbit-user", + :RABBITMQ_PASS "rabbit-pw", + :RABBITMQ_ERLANG_COOKIE "rabbit-erlang", + :DJANGO_SUPERUSER_USERNAME "taiga-admin", + :DJANGO_SUPERUSER_PASSWORD "super-password", + :DJANGO_SUPERUSER_EMAIL "some@example.com"}} + (cut/generate-secret (yaml/load-as-edn "taiga-test/valid-auth.yaml"))))) \ No newline at end of file