|
|
|
@ -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"})))))
|
|
|
|
|