dda-backup/test/dda/backup/restore/domain_test.clj

42 lines
1.6 KiB
Clojure
Raw Normal View History

2024-08-16 17:13:11 +00:00
(ns dda.backup.restore.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.backup.restore.domain :as cut]))
(st/instrument `cut/restore-dir-command)
2024-08-21 06:57:08 +00:00
(st/instrument `cut/restore-db-command)
2024-08-16 17:13:11 +00:00
(deftest should-calculate-restore-dir
(is (= [["rm" "-rf" "dir-to-backup"]
["restic"
"-r"
"repo/dir-at-repo"
"-v"
"restore"
"latest"
"--target"
"dir-to-backup"]]
(cut/restore-dir-command {:restic-repository "repo"
:backup-path "dir-at-repo"
2024-08-21 14:55:59 +00:00
:restore-target-directory "dir-to-backup"
2024-08-16 17:13:11 +00:00
:days-to-keep 39
:months-to-keep 3
:snapshot-id "latest"}))))
2024-08-21 06:57:08 +00:00
(deftest should-calculate-restore-db
(is (= [["bash"
"-c"
(str "restic -r repo/dir-at-repo -v dump latest stdin | "
"psql -d mydb -h localhost -p 5432 -U user --no-password")]]
(cut/restore-db-command {:restic-repository "repo"
:backup-path "dir-at-repo"
:pg-host "localhost"
:pg-port 5432
:pg-db "mydb"
:pg-user "user"
:pg-password "password"
:days-to-keep 39
:months-to-keep 3
:snapshot-id "latest"}))))