From 3d4b5728d19ea2fafd23b5cf2e6a392dea1003bd Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 17 Jun 2022 09:12:03 +0200 Subject: [PATCH] Rewrite tests using new common_test --- project.clj | 2 +- src/test/cljc/dda/c4k_gitea/gitea_test.cljc | 47 ++++++--------------- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/project.clj b/project.clj index a23f2c6..f3c105e 100644 --- a/project.clj +++ b/project.clj @@ -5,7 +5,7 @@ :url "https://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.10.3"] [org.clojure/tools.reader "1.3.6"] - [org.domaindrivenarchitecture/c4k-common-clj "2.0.3"] + [org.domaindrivenarchitecture/c4k-common-clj "2.1.0"] [hickory "0.7.1"]] :target-path "target/%s/" :source-paths ["src/main/cljc" diff --git a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc index 3d4a8e8..d3b5897 100644 --- a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc +++ b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc @@ -2,42 +2,21 @@ (:require #?(:clj [clojure.test :refer [deftest is are testing run-tests]] :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) + [dda.c4k-common.common-test :as ct] [dda.c4k-gitea.gitea :as cut])) - (deftest should-generate-appini-env - (is (= {:apiVersion "v1", - :kind "ConfigMap", - :metadata {:name "gitea-env", :namespace "default"}, - :data - {:GITEA__database__DB_TYPE "postgres", - :GITEA__database__HOST - "postgresql-service.default.svc.cluster.local:5432", - :GITEA__database__NAME "gitea", - :GITEA__database__USER "pg-user", - :GITEA__database__PASSWD "pg-pw", - :GITEA__server__DOMAIN "test.com", - :GITEA__server__ROOT_URL "https://test.com"}} - (cut/generate-appini-env {:fqdn "test.com" :issuer "staging" :postgres-db-user "pg-user" :postgres-db-password "pg-pw"})))) - + (is (= {:GITEA__database__USER-c1 nil, + :GITEA__database__USER-c2 "pg-user", + :GITEA__database__PASSWD-c1 nil, + :GITEA__database__PASSWD-c2 "pg-pw", + :GITEA__server__DOMAIN-c1 nil, + :GITEA__server__DOMAIN-c2 "test.com", + :GITEA__server__ROOT_URL-c1 "https://", + :GITEA__server__ROOT_URL-c2 "https://test.com"} + (ct/map-diff (cut/generate-appini-env {}) + (cut/generate-appini-env {:fqdn "test.com" :issuer "staging" :postgres-db-user "pg-user" :postgres-db-password "pg-pw"}))))) (deftest should-generate-ingress - (is (= {:apiVersion "networking.k8s.io/v1", - :kind "Ingress", - :metadata - {:name "ingress-gitea", - :namespace "default", - :annotations - {:kubernetes.io/ingress.class "traefik", - :cert-manager.io/cluster-issuer "staging"}}, - :spec - {:tls [{:hosts ["test.com"], :secretName "gitea-ingress-cert"}], - :rules - [{:host "test.com", - :http - {:paths - [{:pathType "Prefix", - :path "/", - :backend - {:service {:name "gitea-service", :port {:number 3000}}}}]}}]}} - (cut/generate-ingress {:fqdn "test.com" :issuer "staging"})))) + (is (= {:hosts-c1 nil, :hosts-c2 "test.com", :host-c1 nil, :host-c2 "test.com"} + (ct/map-diff (cut/generate-ingress {}) (cut/generate-ingress {:fqdn "test.com" :issuer "staging"})))))