export RSYNC_LOG="build/test/rsync.log"
export RSYNC_LOG_RUNS="0"
source src/backup
+ mkdir --parents "build/test"
get_date() {
echo "2000-01-01"
}
# bats test_tags=backup:start,backup:config
@test "failure no backup name in config" {
yq() {
- echo '{"backup_path": "path"}'
+ echo '{"backup_path": "build/test"}'
}
run main
assert_failure
assert_line --index 0 "⭐ START: backup"
- assert_line --index 1 "ℹ️ INFO: backup path path"
+ assert_line --index 1 "ℹ️ INFO: backup path build/test"
assert_line --index 2 "❌ ERROR: src/config-example.yaml missing backup_name"
}
@test "failure no backup count in config" {
yq() {
echo '{
- "backup_path": "path",
+ "backup_path": "build/test",
"backup_name": "backup"
}'
}
assert_failure
assert_line --index 0 "⭐ START: backup"
- assert_line --index 1 "ℹ️ INFO: backup path path"
+ assert_line --index 1 "ℹ️ INFO: backup path build/test"
assert_line --index 2 "ℹ️ INFO: backup name backup"
assert_line --index 3 "❌ ERROR: src/config-example.yaml missing backup_count"
}
@test "failure no machines in config" {
yq() {
echo '{
- "backup_path": "path",
+ "backup_path": "build/test",
"backup_name": "backup",
"backup_count": 15
}'
assert_failure
assert_line --index 0 "⭐ START: backup"
- assert_line --index 1 "ℹ️ INFO: backup path path"
+ assert_line --index 1 "ℹ️ INFO: backup path build/test"
assert_line --index 2 "ℹ️ INFO: backup name backup"
assert_line --index 3 "ℹ️ INFO: backup count 15"
assert_line --index 4 "❌ ERROR: src/config-example.yaml missing machines"
}
+# bats test_tags=backup:info
+@test "failed backup path not exists" {
+ rmdir "build/test"
+
+ run main
+
+ assert_failure
+ assert_line --index 0 "⭐ START: backup"
+ assert_line --index 1 "❌ ERROR: backup path build/test not exists"
+}
+
# bats test_tags=backup:info
@test "success info backup count" {
create_backup_dir() {
cleanup_old_backups() {
:
}
+ check_backup_date() {
+ :
+ }
run main
cleanup_old_backups() {
:
}
+ check_backup_date() {
+ :
+ }
run main
cleanup_old_backups() {
:
}
+ check_backup_date() {
+ :
+ }
run main