From 93a36e992ecf52d18ea3e8843ef8597bd2bc4813 Mon Sep 17 00:00:00 2001 From: bom Date: Tue, 28 Mar 2023 12:06:31 +0200 Subject: [PATCH] Test for valid resources --- .gitlab-ci.yml | 2 +- src/test/cljc/dda/c4k_forgejo/core_test.cljc | 19 +++++++++++++++++++ .../resources/forgejo-test/valid-auth.yaml | 0 .../resources/forgejo-test/valid-config.yaml | 4 ++-- valid-auth.edn | 9 --------- valid-config.edn | 12 ------------ 6 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 src/test/cljc/dda/c4k_forgejo/core_test.cljc rename valid-auth.yaml => src/test/resources/forgejo-test/valid-auth.yaml (100%) rename valid-config.yaml => src/test/resources/forgejo-test/valid-config.yaml (86%) delete mode 100644 valid-auth.edn delete mode 100644 valid-config.edn diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7af57b9..6815ca1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ test-schema: stage: build_and_test script: - lein uberjar - - java -jar target/uberjar/c4k-forgejo-standalone.jar valid-config.edn valid-auth.edn | kubeconform --kubernetes-version 1.19.0 --strict --skip Certificate - + - java -jar target/uberjar/c4k-forgejo-standalone.jar src/test/resources/forgejo_test/valid-config.yaml src/test/resources/forgejo_test/valid-auth.yaml | kubeconform --kubernetes-version 1.19.0 --strict --skip Certificate - artifacts: paths: - target/uberjar diff --git a/src/test/cljc/dda/c4k_forgejo/core_test.cljc b/src/test/cljc/dda/c4k_forgejo/core_test.cljc new file mode 100644 index 0000000..5386019 --- /dev/null +++ b/src/test/cljc/dda/c4k_forgejo/core_test.cljc @@ -0,0 +1,19 @@ +(ns dda.c4k-forgejo.core-test + (:require + #?(:cljs [shadow.resource :as rc]) + #?(:clj [clojure.test :refer [deftest is are testing run-tests]] + :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) + [clojure.spec.alpha :as s] + [dda.c4k-common.yaml :as yaml] + [dda.c4k-forgejo.core :as cut])) + +#?(:cljs + (defmethod yaml/load-resource :forgejo-test [resource-name] + (case resource-name + "forgejo-test/valid-auth.yaml" (rc/inline "forgejo-test/valid-auth.yaml") + "forgejo-test/valid-config.yaml" (rc/inline "forgejo-test/valid-config.yaml") + (throw (js/Error. "Undefined Resource!"))))) + +(deftest validate-valid-resources + (is (s/valid? cut/config? (yaml/load-as-edn "forgejo-test/valid-config.yaml"))) + (is (s/valid? cut/auth? (yaml/load-as-edn "forgejo-test/valid-auth.yaml")))) \ No newline at end of file diff --git a/valid-auth.yaml b/src/test/resources/forgejo-test/valid-auth.yaml similarity index 100% rename from valid-auth.yaml rename to src/test/resources/forgejo-test/valid-auth.yaml diff --git a/valid-config.yaml b/src/test/resources/forgejo-test/valid-config.yaml similarity index 86% rename from valid-config.yaml rename to src/test/resources/forgejo-test/valid-config.yaml index 10b63e6..2bcf05b 100644 --- a/valid-config.yaml +++ b/src/test/resources/forgejo-test/valid-config.yaml @@ -9,5 +9,5 @@ volume-total-storage-size: 6 restic-repository: "repo-path" mon-cfg: grafana-cloud-url: "url-for-your-prom-remote-write-endpoint" - k3s-cluster-name: "jitsi" - k3s-cluster-stage: "test" \ No newline at end of file + cluster-name: "jitsi" + cluster-stage: "test" \ No newline at end of file diff --git a/valid-auth.edn b/valid-auth.edn deleted file mode 100644 index d444915..0000000 --- a/valid-auth.edn +++ /dev/null @@ -1,9 +0,0 @@ -{:postgres-db-user "forgejo" - :postgres-db-password "forgejo-db-password" - :mailer-user "" - :mailer-pw "" - :aws-access-key-id "AWS_KEY_ID" - :aws-secret-access-key "AWS_KEY_SECRET" - :restic-password "" - :mon-auth {:grafana-cloud-user "user" - :grafana-cloud-password "password"}} diff --git a/valid-config.edn b/valid-config.edn deleted file mode 100644 index c8d4253..0000000 --- a/valid-config.edn +++ /dev/null @@ -1,12 +0,0 @@ -{:default-app-name "Meissas awesome forgejo" - :fqdn "test.de" - :issuer "staging" - :mailer-from "test@test.de" - :mailer-host-port "test.de:123" - :service-whitelist-domains "test.de" - :service-noreply-address "noreply@test.de" - :volume-total-storage-size 6 - :restic-repository "repo-path" - :mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint" - :k3s-cluster-name "jitsi" - :k3s-cluster-stage "test"}}