|
225 | 225 | [ "$status" -eq 0 ] |
226 | 226 | } |
227 | 227 |
|
| 228 | +@test "batch_uninstall_applications dry-run does not report expected leftovers as failures" { |
| 229 | + create_app_artifacts |
| 230 | + |
| 231 | + run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF' |
| 232 | +set -euo pipefail |
| 233 | +source "$PROJECT_ROOT/lib/core/common.sh" |
| 234 | +source "$PROJECT_ROOT/lib/uninstall/batch.sh" |
| 235 | +
|
| 236 | +request_sudo_access() { return 0; } |
| 237 | +start_inline_spinner() { :; } |
| 238 | +stop_inline_spinner() { :; } |
| 239 | +enter_alt_screen() { :; } |
| 240 | +leave_alt_screen() { :; } |
| 241 | +hide_cursor() { :; } |
| 242 | +show_cursor() { :; } |
| 243 | +remove_apps_from_dock() { :; } |
| 244 | +pgrep() { return 1; } |
| 245 | +pkill() { return 0; } |
| 246 | +sudo() { return 0; } |
| 247 | +
|
| 248 | +export MOLE_DRY_RUN=1 |
| 249 | +export MOLE_DELETE_MODE=trash |
| 250 | +
|
| 251 | +app_bundle="$HOME/Applications/TestApp.app" |
| 252 | +mkdir -p "$app_bundle" |
| 253 | +
|
| 254 | +selected_apps=() |
| 255 | +selected_apps+=("0|$app_bundle|TestApp|com.example.TestApp|0|Never") |
| 256 | +files_cleaned=0 |
| 257 | +total_items=0 |
| 258 | +total_size_cleaned=0 |
| 259 | +
|
| 260 | +output_file="$HOME/dry_run_uninstall.log" |
| 261 | +printf '\n' | batch_uninstall_applications > "$output_file" 2>&1 |
| 262 | +output=$(cat "$output_file") |
| 263 | +
|
| 264 | +[[ -d "$app_bundle" ]] || { echo "WRONG: dry-run removed app bundle"; cat "$output_file"; exit 1; } |
| 265 | +[[ -d "$HOME/Library/Application Support/TestApp" ]] || { echo "WRONG: dry-run removed app support"; cat "$output_file"; exit 1; } |
| 266 | +[[ -d "$HOME/Library/Caches/TestApp" ]] || { echo "WRONG: dry-run removed cache"; cat "$output_file"; exit 1; } |
| 267 | +[[ -f "$HOME/Library/Preferences/com.example.TestApp.plist" ]] || { echo "WRONG: dry-run removed prefs"; cat "$output_file"; exit 1; } |
| 268 | +
|
| 269 | +[[ "$output" == *"Uninstall dry run complete"* ]] || { echo "WRONG: missing dry-run summary"; cat "$output_file"; exit 1; } |
| 270 | +[[ "$output" == *"Would remove 1 app"* ]] || { echo "WRONG: missing would-remove summary"; cat "$output_file"; exit 1; } |
| 271 | +[[ "$output" != *"Could not remove"* ]] || { echo "WRONG: dry-run reported expected leftovers"; cat "$output_file"; exit 1; } |
| 272 | +[[ "$output" != *"Uninstall incomplete"* ]] || { echo "WRONG: dry-run marked incomplete"; cat "$output_file"; exit 1; } |
| 273 | +EOF |
| 274 | + |
| 275 | + [ "$status" -eq 0 ] |
| 276 | +} |
| 277 | + |
228 | 278 | @test "force_kill_app sends only an AppleScript Quit, never a kill signal" { |
229 | 279 | # run_with_timeout invokes its argv via gtimeout/timeout, which exec the |
230 | 280 | # real binary and bypass bash functions, so we shadow osascript via a |
|
0 commit comments