dda-build/test/dda/build/c4k/domain_test.clj

203 lines
8.7 KiB
Clojure
Raw Normal View History

2024-10-04 16:17:19 +02:00
(ns dda.build.c4k.domain-test
(:require
[clojure.test :refer [deftest is]]
[clojure.spec.test.alpha :as st]
[dda.build.c4k.domain :as cut]))
2024-10-04 16:21:02 +02:00
(st/instrument `cut/config-path)
(st/instrument `cut/auth-path)
(st/instrument `cut/output-path)
(st/instrument `cut/clean-build-dir-command)
(st/instrument `cut/c4k-uberjar-command)
(st/instrument `cut/c4k-graalvm-command)
(st/instrument `cut/create-c4k-config)
2024-10-04 16:17:19 +02:00
(deftest should-calculate-config-path
(is (= "../../target/dda-backup/config.yaml"
(cut/config-path {:name "dda-backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"})))
2024-10-04 16:17:19 +02:00
(is (= "../../target/dda/backup/config.yaml"
(cut/config-path {:name "dda"
:module "backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}))))
2024-10-04 16:17:19 +02:00
(deftest should-calculate-auth-path
(is (= "../../target/dda-backup/auth.yaml"
(cut/auth-path {:name "dda-backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"})))
2024-10-04 16:17:19 +02:00
(is (= "../../target/dda/backup/auth.yaml"
(cut/auth-path {:name "dda"
:module "backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}))))
2024-10-04 16:17:19 +02:00
(deftest should-calculate-output-path
(is (= "../../target/dda-backup/out.yaml"
(cut/output-path {:name "dda-backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"})))
2024-10-04 16:17:19 +02:00
(is (= "../../target/dda/backup/out.yaml"
(cut/output-path {:name "dda"
:module "backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}))))
2024-10-04 16:17:19 +02:00
(deftest should-calculate-clean-build-dir-command
(is (= ["rm" "-rf" "../../target/dda-backup"]
(cut/clean-build-dir-command {:name "dda-backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}))))
2024-10-04 16:17:19 +02:00
(deftest should-calculate-c4k-uberjar-command
2025-01-07 17:51:46 +01:00
(is (= [["bash" "-c" "c4k-backup-standalone.jar ../../target/dda-backup/backup/config.yaml ../../target/dda-backup/backup/auth.yaml > ../../target/dda-backup/backup/out.yaml"]]
2024-10-04 16:17:19 +02:00
(cut/c4k-uberjar-command {:name "dda-backup"
2025-01-07 17:51:46 +01:00
:module "backup"
2024-10-04 16:17:19 +02:00
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}))))
2024-10-04 16:17:19 +02:00
(deftest should-calculate-c4k-graalvm-command
2025-01-07 17:51:46 +01:00
(is (= [["bash" "-c" "c4k-backup ../../target/dda-backup/backup/config.yaml ../../target/dda-backup/backup/auth.yaml > ../../target/dda-backup/backup/out.yaml"]]
2024-10-04 16:17:19 +02:00
(cut/c4k-graalvm-command {:name "dda-backup"
2025-01-07 17:51:46 +01:00
:module "backup"
2024-10-04 16:17:19 +02:00
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
2025-01-08 10:32:22 +01:00
:c4k-app-name "backup"
2025-01-07 17:51:46 +01:00
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}))))
2024-10-04 16:17:19 +02:00
2025-01-09 18:02:59 +01:00
(deftest should-create-c4k-config
(is (= {:fqdn "cloud.test.meissa.de",
:issue "staging",
:restic-repository "restic-repo",
:pv-storage-size-gb 40,
:pvc-storage-class-name "hcloud-volumes-encrypted"}
(cut/create-c4k-config
{:issue "staging"
:restic-repository "restic-repo"
:pv-storage-size-gb 40
:pvc-storage-class-name "hcloud-volumes-encrypted"}
{:name "dda"
:module "backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:c4k-app-name "backup"
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}
{:out
{:sensitive false,
:type [],
:value {:fqdn "cloud.test.meissa.de",
:ipv4 "91.107.220.172",
:ipv6 "2a01:4f8:c17:86c6::1"}}})))
(is (= {:fqdn "cloud.test.meissa.de",
:issue "staging",
:restic-repository "restic-repo",
:pv-storage-size-gb 40,
:pvc-storage-class-name "hcloud-volumes-encrypted"
:mon-cfg
{:grafana-cloud-url "https://prometheus-endpoint",
:cluster-name "dda-backup",
:cluster-stage "dev"}}
(cut/create-c4k-config
{:issue "staging"
:restic-repository "restic-repo"
:pv-storage-size-gb 40
:pvc-storage-class-name "hcloud-volumes-encrypted"}
{:name "dda"
:module "backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:grafana-cloud-url "https://prometheus-endpoint"
:c4k-app-name "backup"
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"}
{:out
{:sensitive false,
:type [],
:value {:fqdn "cloud.test.meissa.de",
:ipv4 "91.107.220.172",
:ipv6 "2a01:4f8:c17:86c6::1"}}}))))