]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
change param test to backward compatible
authorBastian Dehn <hhaalo@arcor.de>
Sun, 9 Aug 2026 10:43:16 +0000 (12:43 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 9 Aug 2026 10:43:16 +0000 (12:43 +0200)
builder/Containerfile.template
tests/backup_tests.bats

index c4706daa2d09effd2f557ba279ac367d9a4f2333..2d989c49e3c0f27cfd48275a780c541a5413e035 100644 (file)
@@ -18,6 +18,10 @@ RUN apt-get update \
        bats-support \
        bats-assert \
        shellcheck \
+       yq \
+       jq \
+       ssh \
+       rsync \
        && apt-get clean \
        && rm --recursive --force /var/lib/apt/lists/*
 COPY run /app/run
index 3c3ccfcef1693c76b3a6923fb59aed1833e4afb9..88c0c4365967a75bc27e023243e9f11bb1fb1d84 100755 (executable)
@@ -873,10 +873,26 @@ teardown() {
        assert_output ""
 }
 
-write_log_entry() {
-       local type="$1"
+# bats test_tags=backup:log
+@test "success log has logfile entry for type none" {
+       mkdir --parents build/test
+       local config=
+       config=$(yq '.' "$CONFIG_FILE")
+       get_date_time() {
+               echo "2000-01-01T23:30:45+02:00"
+       }
+
+       run log "$config" "log entry"
+
+       assert_success
+       assert_output "ℹ️ INFO: 2000-01-01T23:30:45+02:00 [none] log entry -> build/test/backup.log"
+       assert_equal "$(cat "build/test/backup.log")" "2000-01-01T23:30:45+02:00 [none] log entry"
+}
+
+# bats test_tags=backup:log
+@test "success log has logfile entry for type day" {
        mkdir --parents build/test
-       touch "build/test/$type"
+       touch build/test/day
        local config=
        config=$(yq '.' "$CONFIG_FILE")
        get_date_time() {
@@ -886,16 +902,43 @@ write_log_entry() {
        run log "$config" "log entry"
 
        assert_success
-       assert_output "ℹ️ INFO: 2000-01-01T23:30:45+02:00 [$type] log entry -> build/test/backup.log"
-       assert_equal "$(cat "build/test/backup.log")" "2000-01-01T23:30:45+02:00 [$type] log entry"
+       assert_output "ℹ️ INFO: 2000-01-01T23:30:45+02:00 [day] log entry -> build/test/backup.log"
+       assert_equal "$(cat "build/test/backup.log")" "2000-01-01T23:30:45+02:00 [day] log entry"
 }
 
-for type in none day week month; do
-       bats_test_function --tags "backup:log" \
-               --description "success log has logfile entry for type $type" \
-               -- \
-               write_log_entry "$type"
-done
+# bats test_tags=backup:log
+@test "success log has logfile entry for type week" {
+       mkdir --parents build/test
+       touch build/test/week
+       local config=
+       config=$(yq '.' "$CONFIG_FILE")
+       get_date_time() {
+               echo "2000-01-01T23:30:45+02:00"
+       }
+
+       run log "$config" "log entry"
+
+       assert_success
+       assert_output "ℹ️ INFO: 2000-01-01T23:30:45+02:00 [week] log entry -> build/test/backup.log"
+       assert_equal "$(cat "build/test/backup.log")" "2000-01-01T23:30:45+02:00 [week] log entry"
+}
+
+# bats test_tags=backup:log
+@test "success log has logfile entry for type month" {
+       mkdir --parents build/test
+       touch build/test/month
+       local config=
+       config=$(yq '.' "$CONFIG_FILE")
+       get_date_time() {
+               echo "2000-01-01T23:30:45+02:00"
+       }
+
+       run log "$config" "log entry"
+
+       assert_success
+       assert_output "ℹ️ INFO: 2000-01-01T23:30:45+02:00 [month] log entry -> build/test/backup.log"
+       assert_equal "$(cat "build/test/backup.log")" "2000-01-01T23:30:45+02:00 [month] log entry"
+}
 
 # bats test_tags=backup:log
 @test "success no logrotate by 99 lines" {