fix(cli): skip volume access during suppression previews

This commit is contained in:
2026-10-30 11:31:43 -03:00
parent 60ddbff5e2
commit 870ac48d02
3 changed files with 53 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bats
run_preview() {
local script="$1" command="$2" recovery="$3"
local definitions="$BATS_TEST_TMPDIR/preview.functions"
sed '/^main "\$@"$/d' "$script" > "$definitions"
run "${UNLEASH_TEST_SHELL:-bash}" -u -c '
source "$1"
action="$2" recovery="$3"
load_config() { :; }
is_recovery() { return "$recovery"; }
resolve_data_volume() { echo TARGET_WAS_ACCESSED; return 97; }
main --dry-run "$action"
' "$script" "$definitions" "$command" "$recovery"
}
@test "suppress and bypass dry runs return before target resolution" {
local entrypoint action
for entrypoint in unleash unleash-standalone.sh; do
for action in suppress bypass; do
run_preview "$BATS_TEST_DIRNAME/../$entrypoint" "$action" 0
[ "$status" -eq 0 ]
[[ "$output" == *"[DRY RUN]"* ]]
[[ "$output" != *"TARGET_WAS_ACCESSED"* ]]
done
done
}
@test "bypass dry run still rejects a booted OS" {
local entrypoint
for entrypoint in unleash unleash-standalone.sh; do
run_preview "$BATS_TEST_DIRNAME/../$entrypoint" bypass 1
[ "$status" -ne 0 ]
[[ "$output" == *"Full bypass must run from Recovery mode"* ]]
[[ "$output" != *"TARGET_WAS_ACCESSED"* ]]
done
}