1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 16:45:07 +00:00

fix(main): preserve versioned app names and clean mise cache

This commit is contained in:
Tw93
2026-03-22 14:45:21 +08:00
parent dca5bd5b0e
commit 0c71ee9363
4 changed files with 103 additions and 0 deletions

View File

@@ -206,6 +206,23 @@ EOF
[[ "$output" == *"Docker unused data|Docker unused data docker system prune -af --volumes"* ]]
}
@test "clean_dev_mise respects MISE_CACHE_DIR and only targets cache" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" MISE_CACHE_DIR="/tmp/mise-cache" bash --noprofile --norc <<'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/core/common.sh"
source "$PROJECT_ROOT/lib/clean/dev.sh"
safe_clean() { echo "$2|$1"; }
clean_tool_cache() { :; }
note_activity() { :; }
run_with_timeout() { shift; "$@"; }
clean_dev_mise
EOF
[ "$status" -eq 0 ]
[[ "$output" == *"mise cache|/tmp/mise-cache/*"* ]]
[[ "$output" != *".local/share/mise"* ]]
}
@test "clean_developer_tools runs key stages" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
set -euo pipefail
@@ -217,6 +234,7 @@ clean_homebrew() { echo "brew"; }
clean_project_caches() { :; }
clean_dev_python() { :; }
clean_dev_go() { :; }
clean_dev_mise() { echo "mise"; }
clean_dev_rust() { :; }
check_rust_toolchains() { :; }
check_android_ndk() { :; }
@@ -248,6 +266,7 @@ EOF
[ "$status" -eq 0 ]
[[ "$output" == *"npm"* ]]
[[ "$output" == *"mise"* ]]
[[ "$output" == *"brew"* ]]
}

View File

@@ -260,6 +260,44 @@ EOF
[ "$status" -eq 0 ]
}
@test "uninstall_resolve_display_name keeps versioned app names when metadata is generic" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/core/common.sh"
function run_with_timeout() {
shift
"$@"
}
function mdls() {
echo "Xcode"
}
function plutil() {
if [[ "$3" == *"Info.plist" ]]; then
echo "Xcode"
return 0
fi
return 1
}
MOLE_UNINSTALL_USER_LC_ALL=""
MOLE_UNINSTALL_USER_LANG=""
eval "$(sed -n '/^uninstall_resolve_display_name()/,/^}/p' "$PROJECT_ROOT/bin/uninstall.sh")"
app_path="$HOME/Applications/Xcode 16.4.app"
mkdir -p "$app_path/Contents"
touch "$app_path/Contents/Info.plist"
result=$(uninstall_resolve_display_name "$app_path" "Xcode 16.4.app")
[[ "$result" == "Xcode 16.4" ]] || exit 1
EOF
[ "$status" -eq 0 ]
}
@test "decode_file_list handles empty input" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
set -euo pipefail