Files
coredesktop/tests/migrations.bats
T
2026-11-27 12:48:07 -07:00

79 lines
2.3 KiB
Bash

#!/usr/bin/env bats
load test_helper
# Migrations that change files in the user's home
SKIP="$BATS_TEST_TMPDIR/home/.config/coredesktop/skip-packages"
THUNDERBIRD="$REPO/migrations/1794160046.sh"
skip_list() {
mkdir -p "$(dirname "$SKIP")"
printf "$1" > "$SKIP"
}
@test "skipping the old Thunderbird ID carries over to the new one" {
skip_list 'foo\norg.mozilla.Thunderbird # no mail'
run bash "$THUNDERBIRD"
[ "$status" -eq 0 ]
[ "$(cat "$SKIP")" = "$(printf 'foo\norg.mozilla.Thunderbird # no mail\norg.mozilla.thunderbird_esr')" ]
}
@test "the Thunderbird migration leaves other skip lists alone" {
for list in 'org.mozilla.ThunderbirdX\n' 'org.mozilla.Thunderbird\norg.mozilla.thunderbird_esr\n'; do
skip_list "$list"
before="$(cat "$SKIP")"
run bash "$THUNDERBIRD"
[ "$status" -eq 0 ]
[ "$(cat "$SKIP")" = "$before" ]
done
rm -f "$SKIP"
run bash "$THUNDERBIRD"
[ "$status" -eq 0 ]
[ ! -e "$SKIP" ]
}
# --- Top bar menu package (1795806218) ---------------------------------------
MENU="$REPO/migrations/1795806218.sh"
MENU_UUID=coredesktop@federated.computer
# menu_setup INSTALLED: link CoreDesktop into the test home, and fake pacman
# with the menu's package installed if INSTALLED is yes, and gsettings
menu_setup() {
mkdir -p "$HOME/.local/share"
ln -s "$REPO" "$HOME/.local/share/coredesktop"
if [ "$1" = yes ]; then
stub pacman '[ "$2" = gnome-shell-extension-coredesktop ]'
else
stub pacman 'exit 1'
fi
export GSETTINGS="$BATS_TEST_TMPDIR/enabled-extensions"
printf '%s' "['a@b']" > "$GSETTINGS"
stub gsettings 'case "$1" in get) cat "$GSETTINGS" ;; set) printf "%s" "$4" > "$GSETTINGS" ;; esac'
}
@test "the menu migration turns on the package's extension and removes a hand-installed copy" {
menu_setup yes
copy="$HOME/.local/share/gnome-shell/extensions/$MENU_UUID"
mkdir -p "$copy"
touch "$copy/metadata.json"
run bash "$MENU"
[ "$status" -eq 0 ]
[ ! -e "$copy" ]
[ "$(cat "$GSETTINGS")" = "['a@b', '$MENU_UUID']" ]
}
@test "the menu migration fails, to run again, until the package is installed" {
menu_setup no
copy="$HOME/.local/share/gnome-shell/extensions/$MENU_UUID"
mkdir -p "$copy"
run bash "$MENU"
[ "$status" -ne 0 ]
# Still the only copy there is
[ -d "$copy" ]
[ "$(cat "$GSETTINGS")" = "['a@b']" ]
}