dda-build/test/dda/build/provs/domain_test.clj
2025-01-09 15:07:26 +01:00

92 lines
3.8 KiB
Clojure

(ns dda.build.provs.domain-test
(:require
[clojure.test :refer [deftest is]]
[clojure.spec.test.alpha :as st]
[dda.build.provs.domain :as cut]))
(st/instrument `cut/output-path)
(st/instrument `cut/provs-server-command)
(st/instrument `cut/create-k3s-config)
(deftest should-calculate-provs-server-command
(is (= [["provs-server.jar" "k3s" "root@127.0.0.1" "-c" "../../target/dda-backup/k3s-out.yaml" "-a" "../../target/dda-backup/out.yaml"]]
(cut/provs-server-command {:name "dda-backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:c4k-app-name "backup"
:k3s-output-filename "k3s-out.yaml"
:k3s-auth-input "k3s-auth.edn"
:k3s-provision-user "root"
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"
:email "test@test.t"
:echo false}
{:out {:sensitive false :type [] :value {:fqdn "test.test.de" :ipv4 "127.0.0.1" :ipv6 "::"}}}))))
(deftest should-create-k3s-config
(is (= {:fqdn "cloud.test.meissa.de",
:node {:ipv4 "91.107.220.172", :ipv6 "2a01:4f8:c17:86c6::1"},
:certmanager {:email "test@test.t", :letsencryptEndpoint "staging"},
:echo false,
:hetzner
{:hcloudApiToken {:source "PLAIN", :parameter "hcloud-token"},
:encryptionPassphrase {:source "PLAIN", :parameter "passphrase"}}}
(cut/create-k3s-config
{:name "dda-backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:c4k-app-name "backup"
:k3s-output-filename "k3s-out.yaml"
:k3s-auth-input "k3s-auth.edn"
:k3s-provision-user "root"
:k3s-hcloudApiToken "hcloud-token"
:k3s-encryptionPassphrase "passphrase"
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"
:email "test@test.t"
:echo false}
{: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",
:node {:ipv4 "91.107.220.172", :ipv6 "2a01:4f8:c17:86c6::1"},
:certmanager {:email "test@test.t", :letsencryptEndpoint "staging"},
:echo false,}
(cut/create-k3s-config
{:name "dda-backup"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:c4k-app-name "backup"
:k3s-output-filename "k3s-out.yaml"
:k3s-auth-input "k3s-auth.edn"
:k3s-provision-user "root"
:k3s-encryptionPassphrase "passphrase"
:c4k-config-input "config.yaml"
:c4k-auth-input "auth.yaml"
:c4k-output "out.yaml"
:email "test@test.t"
:echo false}
{:out
{:sensitive false,
:type [],
:value {:fqdn "cloud.test.meissa.de",
:ipv4 "91.107.220.172",
:ipv6 "2a01:4f8:c17:86c6::1"}}}))))