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

42 lines
1.8 KiB
Clojure
Raw Permalink Normal View History

2024-08-20 05:56:13 +00:00
(ns dda.backup.postgresql.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.backup.postgresql.domain :as cut]))
(st/instrument `cut/pgpass)
2024-08-23 15:47:32 +00:00
(st/instrument `cut/db-drop-command)
(st/instrument `cut/db-create-command)
2024-08-20 05:56:13 +00:00
(deftest should-calculate-pgpass
2024-08-23 15:47:32 +00:00
(is (= "localhost:5432:mydb:user:password\nlocalhost:5432:template1:user:password\n"
2024-08-20 05:56:13 +00:00
(cut/pgpass {:restic-repository "repo"
:backup-path "dir-at-repo"
:pg-host "localhost"
:pg-port 5432
:pg-db "mydb"
:pg-user "user"
:pg-password "password"}))))
2024-08-23 15:47:32 +00:00
(deftest should-calculate-db-drop-command
2024-08-20 05:56:13 +00:00
(is (= [["psql" "-d" "template1" "-h" "localhost" "-p" "5432" "-U" "user"
2024-08-23 15:47:32 +00:00
"--no-password" "-c" "DROP DATABASE \"mydb\";"]]
(cut/db-drop-command {:restic-repository "repo"
:backup-path "dir-at-repo"
:pg-host "localhost"
:pg-port 5432
:pg-db "mydb"
:pg-user "user"
:pg-password "password"}))))
(deftest should-calculate-db-create-command
(is (= [["psql" "-d" "template1" "-h" "localhost" "-p" "5432" "-U" "user"
"--no-password" "-c" "CREATE DATABASE \"mydb\";"]]
(cut/db-create-command {:restic-repository "repo"
2024-08-20 05:56:13 +00:00
:backup-path "dir-at-repo"
:pg-host "localhost"
:pg-port 5432
:pg-db "mydb"
:pg-user "user"
:pg-password "password"}))))