wrote tests upfront

This commit is contained in:
Michael Jerger 2023-05-30 09:20:58 +02:00
parent 2af76f8557
commit b689d520ce
5 changed files with 20 additions and 16 deletions

View file

@ -43,7 +43,7 @@
(postgres/generate-deployment {:postgres-image "postgres:14"
:postgres-size :2gb})
(postgres/generate-service)
(forgejo/generate-deployment)
(forgejo/generate-deployment config)
(forgejo/generate-service)
(forgejo/generate-service-ssh)
(forgejo/generate-data-volume config)

View file

@ -21,7 +21,7 @@
(pred/string-of-separated-by? pred/fqdn-string? #"," input)))
(s/def ::default-app-name string?)
(s/def ::forgejo-image-name string?)
(s/def ::federated boolean?)
(s/def ::fqdn pred/fqdn-string?)
(s/def ::mailer-from pred/bash-env-string?)
(s/def ::mailer-host pred/bash-env-string?)
@ -39,11 +39,11 @@
::mailer-from
::mailer-host
::mailer-port
::service-noreply-address
::deploy-federated]
::service-noreply-address]
:opt-un [::issuer
::default-app-name
::service-domain-whitelist]))
::service-domain-whitelist
::federated]))
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::mailer-user ::mailer-pw]))
@ -121,13 +121,7 @@
; ToDo: Need to add default image-name to config? Or hardcode?
(defn-spec generate-deployment pred/map-or-seq?
[config config?]
(let [{:keys [deploy-federated]} config
deploy-federated-bool (boolean (Boolean/valueOf deploy-federated))]
(->
(yaml/load-as-edn "forgejo/deployment.yaml")
#(if deploy-federated-bool
(cm/replace-all-matching-values-by-new-value % "IMAGE_NAME" federated-image-name)
(cm/replace-all-matching-values-by-new-value %"IMAGE_NAME" default-name)))))
(yaml/load-as-edn "forgejo/deployment.yaml"))
(defn generate-service
[]

View file

@ -18,7 +18,7 @@ spec:
spec:
containers:
- name: forgejo
image: codeberg.org/meissa/forgejo:federated-latest #codeberg.org/forgejo/forgejo:1.19
image: codeberg.org/forgejo/forgejo:1.19
imagePullPolicy: IfNotPresent
# config settings
envFrom:

View file

@ -29,7 +29,9 @@
:FORGEJO__service__EMAIL_DOMAIN_WHITELIST-c1 "adb.de",
:FORGEJO__service__EMAIL_DOMAIN_WHITELIST-c2 "test.com,test.net",
:FORGEJO__service__NO_REPLY_ADDRESS-c1 "",
:FORGEJO__service__NO_REPLY_ADDRESS-c2 "noreply@test.com"}
:FORGEJO__service__NO_REPLY_ADDRESS-c2 "noreply@test.com"
:FORGEJO__federation__ENABLED-c1 "true"
:FORGEJO__federation__ENABLED-c2 "false"}
(th/map-diff (cut/generate-appini-env {:default-app-name ""
:fqdn "test.de"
:mailer-from ""
@ -37,6 +39,7 @@
:mailer-port "123"
:service-domain-whitelist "adb.de"
:service-noreply-address ""
:federated true
})
(cut/generate-appini-env {:default-app-name "test forgejo"
:fqdn "test.com"
@ -45,6 +48,7 @@
:mailer-port "456"
:service-domain-whitelist "test.com,test.net"
:service-noreply-address "noreply@test.com"
:federated false
})))))
(deftest should-generate-secret
@ -69,4 +73,10 @@
(is (= {:storage-c1 "1Gi",
:storage-c2 "15Gi"}
(th/map-diff (cut/generate-data-volume {:volume-total-storage-size 1})
(cut/generate-data-volume {:volume-total-storage-size 15})))))
(cut/generate-data-volume {:volume-total-storage-size 15})))))
(deftest should-generate-deployment
(is (= {:image-c1 "codeberg.org/forgejo/forgejo:1.19",
:image-c2 "domaindrivenarchitecture/c4k-forgejo-fed"}
(th/map-diff (cut/generate-deployment {:federated false})
(cut/generate-deployment {:federated true})))))

View file

@ -8,7 +8,7 @@ service-whitelist-domains: "test.de"
service-noreply-address: "noreply@test.de"
volume-total-storage-size: 6
restic-repository: "repo-path"
deploy-federated: "false"
federated: false
mon-cfg:
grafana-cloud-url: "url-for-your-prom-remote-write-endpoint"
cluster-name: "forgejo"