]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add test for success close volume
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 18:11:53 +0000 (20:11 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 18:11:53 +0000 (20:11 +0200)
src/backupmount
tests/backupmount_tests.bats

index 630130a8a67b0a212473aafb38ede140dff13473..10b7a3b3d3a28647882a3d3f50bdbd98f2182dbd 100755 (executable)
@@ -112,7 +112,7 @@ mount_device()
                || errlog "missing backup path in $CONFIG_FILE" \
                || return $?
 
-       cryptsetupargs=("open"
+       local cryptsetupargs=("open"
                "--key-file $key"
                "$device"
                "$volume")
@@ -170,6 +170,10 @@ umount_backup()
        rmdir "$backup_path" \
                || errlog "could not delete directory $backup_path" \
                || return $?
+
+       echo "ℹ️ INFO: close volume $volume"
+       local cryptsetupargs=("close" "$volume")
+       cryptsetup "${cryptsetupargs[@]}"
 }
 
 main()
index 12b4b918e740639697c79303ca261cb75919282e..6fdc36034bbe8f67c807e874e123576353e6bc1f 100755 (executable)
@@ -522,6 +522,9 @@ teardown() {
        umount() {
                return 0
        }
+       cryptsetup() {
+               return 0
+       }
 
        run main "umount"
 
@@ -548,4 +551,26 @@ teardown() {
        assert_line --index 1 "ℹ️ INFO: umount backup path build/test"
        assert_line --index 2 "ℹ️ INFO: remove backup directory build/test"
        assert_line --index 3 "❌ ERROR: could not delete directory build/test"
+}
+
+# bats test_tags=backupmount:umount
+@test "success close volume with cryptsetup" {
+       umount() {
+               return 0
+       }
+       rmdir() {
+               return 0
+       }
+
+       run main "umount"
+
+       assert_success
+       assert_line --index 0 "⭐ START: backupmount"
+       assert_line --index 1 "ℹ️ INFO: umount backup path build/test"
+       assert_line --index 2 "ℹ️ INFO: remove backup directory build/test"
+       assert_line --index 3 "ℹ️ INFO: close volume luks-crypt-volume"
+       assert_line --index 4 "✅ SUCCESS: backupmount"
+       assert_equal "$(awk 'NR==1 {print; exit}' "$CRYPTSETUP_LOG")" "2"
+       assert_equal "$(awk 'NR==2 {print; exit}' "$CRYPTSETUP_LOG")" "close"
+       assert_equal "$(awk 'NR==3 {print; exit}' "$CRYPTSETUP_LOG")" "luks-crypt-volume"
 }
\ No newline at end of file