dda-build/test/dda/build/terragrunt/domain_test.clj
2024-08-14 20:06:47 +02:00

96 lines
5 KiB
Clojure

(ns dda.build.terragrunt.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.build.terragrunt.domain :as cut]))
(st/instrument `cut/clean-build-dir-command)
(st/instrument `cut/copy-terragrunt-command)
(st/instrument `cut/terragrunt-plan-command)
(st/instrument `cut/terragrunt-apply-command)
(st/instrument `cut/terragrunt-destroy-command)
(deftest should-calculate-clean-build-dir-command
(is (= ["rm" "-rf" "../../target/test"]
(cut/clean-build-dir-command {:name "test"
:module "statistics"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:autoapply false
:tg-output-filenname "tg-out.json"}))))
(deftest should-calculate-copy-terragrunt-command
(is (= [["bash" "-c" "cp *.hcl ../../target/test"]
["cp" "-r" "statistics" "../../target/test"]]
(cut/copy-terragrunt-command {:name "test"
:module "statistics"
:project-root-path "../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:autoapply false
:tg-output-filenname "tg-out.json"}))))
(deftest should-calculate-terragrunt-plan-command
(is (= [[{:dir "../../../target/test/statistics"} "terragrunt" "init"]
[{:dir "../../../target/test/statistics"} "terragrunt" "plan"]]
(cut/terragrunt-plan-command {:name "test"
:module "statistics"
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:autoapply false
:tg-output-filenname "tg-out.json"}))))
(deftest should-calculate-terragrunt-apply-command
(is (= [[{:dir "../../../target/test/statistics"} "terragrunt" "init"]
[{:dir "../../../target/test/statistics"} "terragrunt" "apply" "-auto-approve"]]
(cut/terragrunt-apply-command {:name "test"
:module "statistics"
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:autoapply false
:tg-output-filenname "tg-out.json"}))))
(deftest should-calculate-terragrunt-destroy-command
(is (= [[{:dir "../../../target/test/statistics"} "terragrunt" "init"]
[{:dir "../../../target/test/statistics"} "terragrunt" "destroy"]]
(cut/terragrunt-destroy-command {:name "test"
:module "statistics"
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:autoapply false
:tg-output-filenname "tg-out.json"}))))
(deftest should-calculate-terragrunt-output-command
(is (= [[{:dir "../../../target/test/statistics"} "bash"
"-c"
"terragrunt output -json > tg-out.json"]]
(cut/terragrunt-output-command {:name "test"
:module "statistics"
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false
:autoapply false
:tg-output-filenname "tg-out.json"}))))