add test instrumentation

This commit is contained in:
Michael Jerger 2024-03-13 16:17:35 +01:00
parent 10bf635cdf
commit 7ea24fffb5
6 changed files with 29 additions and 17 deletions

View file

@ -1,2 +0,0 @@
#!/usr/bin/env bb

View file

@ -9,7 +9,7 @@
(s/def ::project-root-path ::domain/project-root-path) (s/def ::project-root-path ::domain/project-root-path)
(s/def ::build-dir-name ::domain/build-dir-name) (s/def ::build-dir-name ::domain/build-dir-name)
(s/def ::devops (s/def ::devops
(s/keys :req-un [::name] (s/keys :req-un [::name]
:opt-un [::module ::stage ::project-root-path ::build-dir-name])) :opt-un [::module ::stage ::project-root-path ::build-dir-name]))

View file

@ -5,7 +5,7 @@
[dda.devops-build.devops.domain :as dd] [dda.devops-build.devops.domain :as dd]
[dda.devops-build.image.domain :as domain])) [dda.devops-build.image.domain :as domain]))
(def default (def default
(merge d/default {})) (merge d/default {}))
(defn-spec dbuild nil? (defn-spec dbuild nil?

View file

@ -8,7 +8,6 @@
(let [{:keys [name]} devops] (let [{:keys [name]} devops]
["cp" "-r" "image" (d/build-path devops)])) ["cp" "-r" "image" (d/build-path devops)]))
(defn-spec dbuild-command seq? (defn-spec dbuild-command seq?
[devops ::d/devops] [devops ::d/devops]
(let [{:keys [name]} devops] (let [{:keys [name]} devops]

View file

@ -1,32 +1,40 @@
(ns dda.devops-build.devops.domain-test (ns dda.devops-build.devops.domain-test
(:require (:require
[clojure.test :refer [deftest is are testing run-tests]] [clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.devops-build.devops.domain :as cut])) [dda.devops-build.devops.domain :as cut]))
(st/instrument `cut/build-path)
(st/instrument `cut/create-build-dir-command)
(deftest should-calculate-build-path (deftest should-calculate-build-path
(is (= "../../target/dda-backup" (is (= "../../target/dda-backup"
(cut/build-path {:name "dda-backup" (cut/build-path {:name "dda-backup"
:project-root-path "../.." :project-root-path "../.."
:build-dir-name "target" :build-dir-name "target"
:version "4.11.8-dev"}))) :version "4.11.8-dev"
:stage "dev"})))
(is (= "../../target/dda/backup" (is (= "../../target/dda/backup"
(cut/build-path {:name "dda" (cut/build-path {:name "dda"
:module "backup" :module "backup"
:project-root-path "../.." :project-root-path "../.."
:build-dir-name "target" :build-dir-name "target"
:version "4.11.8-dev"})))) :version "4.11.8-dev"
:stage "dev"}))))
(deftest should-calculate-clean-build-dir-command (deftest should-calculate-clean-build-dir-command
(is (= ["rm" "-rf" "../../target/dda-backup"] (is (= ["rm" "-rf" "../../target/dda-backup"]
(cut/clean-build-dir-command {:name "dda-backup" (cut/clean-build-dir-command {:name "dda-backup"
:project-root-path "../.." :project-root-path "../.."
:build-dir-name "target" :build-dir-name "target"
:version "4.11.8-dev"})))) :version "4.11.8-dev"
:stage "dev"}))))
(deftest should-calculate-create-build-dir-command (deftest should-calculate-create-build-dir-command
(is (= ["mkdir" "-p" "../../target/dda-backup"] (is (= ["mkdir" "-p" "../../target/dda-backup"]
(cut/create-build-dir-command {:name "dda-backup" (cut/create-build-dir-command {:name "dda-backup"
:project-root-path "../.." :project-root-path "../.."
:build-dir-name "target" :build-dir-name "target"
:version "4.11.8-dev"})))) :version "4.11.8-dev"
:stage "dev"}))))

View file

@ -1,14 +1,20 @@
(ns dda.devops-build.image.domain-test (ns dda.devops-build.image.domain-test
(:require (:require
[clojure.test :refer [deftest is are testing run-tests]] [clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.devops-build.image.domain :as cut])) [dda.devops-build.image.domain :as cut]))
(st/instrument `cut/copy-image-command)
(st/instrument `cut/dbuild-command)
(deftest should-calculate-copy-image-command (deftest should-calculate-copy-image-command
(is (= ["cp" "-r" "image" "../../target/dda-backup"] (is (= ["cp" "-r" "image" "../../target/dda-backup"]
(cut/copy-image-command {:name "dda-backup" (cut/copy-image-command {:name "dda-backup"
:project-root-path "../.." :project-root-path "../.."
:build-dir-name "target" :build-dir-name "target"
:version "4.11.8-dev"})))) :version "4.11.8-dev"
:stage "dev"}))))
(deftest should-calculate-dbuild-command (deftest should-calculate-dbuild-command
(is (= ["docker" (is (= ["docker"
@ -19,7 +25,8 @@
"../../target/dda-backup/image/Dockerfile" "../../target/dda-backup/image/Dockerfile"
"../../target/dda-backup/image"] "../../target/dda-backup/image"]
(cut/dbuild-command {:name "dda-backup" (cut/dbuild-command {:name "dda-backup"
:project-root-path "../.." :project-root-path "../.."
:build-dir-name "target" :build-dir-name "target"
:version "4.11.8-dev"})))) :version "4.11.8-dev"
:stage "dev"}))))