Files
HamPack/tests/installers.bats
T
David YoungandClaude Opus 5.5 bb5c7900d5 Ask for the VARA and Winlink zips when winlink.org won't serve them
downloads.winlink.org now puts a Cloudflare browser check in front of
every page, so the installers' download fails with a 403 and updates
ended with an error (report CD-NTEU79). Look for the zip in the user's
Downloads folder first, and if it isn't there and the site refuses,
list which zips to download and from where instead of failing the
update. A zip that won't extract or an installer that doesn't finish
is still an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:06:01 -07:00

126 lines
4.5 KiB
Bash

#!/usr/bin/env bats
#
# install-windows-apps.sh, install-flatpaks.sh and patch-potacat.sh
load helpers
setup() {
setup_fake_home
fake_coredesktop
stub curl 'exit 1'
# So xdg-user-dir reads the fake home's (absent) settings, not the real ones
export XDG_CONFIG_HOME="$HOME/.config"
}
install_all_windows_apps() {
local c="$HOME/.wine/drive_c"
mkdir -p "$c/VARA" "$c/VARA FM" "$c/RMS Express"
touch "$c/VARA/VARA.exe" "$c/VARA/VARA Terminal.exe" "$c/VARA FM/VARAFM.exe" "$c/RMS Express/RMS Express.exe"
}
@test "windows apps: when all are installed, nothing is downloaded or run" {
install_all_windows_apps
export DISPLAY=:0
run bash "$REPO/install-windows-apps.sh"
[ "$status" -eq 0 ]
! grep -qE '^(curl|winetricks|wine) ' "$STUB_LOG"
}
@test "windows apps: VARA Terminal is installed even when VARA HF is" {
install_all_windows_apps
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
export DISPLAY=:0
run bash "$REPO/install-windows-apps.sh"
[[ "$output" == *"VARA HF is already installed"* ]]
grep -q "^curl .*VARA%20Products" "$STUB_LOG"
}
@test "windows apps: when winlink.org refuses the download, the user is asked to download it and the update isn't failed" {
install_all_windows_apps
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
export DISPLAY=:0
run bash "$REPO/install-windows-apps.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"VARA Terminal, from https://downloads.winlink.org/VARA%20Products/"* ]]
[[ "$output" == *"Leave them in $HOME/Downloads"* ]]
[[ "$output" != *"VARA HF, from"* ]]
! grep -q '^wine .*\.exe' "$STUB_LOG"
}
@test "windows apps: a zip in the downloads folder is installed without downloading" {
install_all_windows_apps
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
mkdir -p "$HOME/Downloads" "$BATS_TEST_TMPDIR/zip"
touch "$BATS_TEST_TMPDIR/zip/VARA Terminal setup.exe"
(cd "$BATS_TEST_TMPDIR/zip" && zip -q "$HOME/Downloads/VARA Terminal v1.2.3 setup.zip" "VARA Terminal setup.exe")
stub wine 'case "$1" in *.exe) touch "$HOME/.wine/drive_c/VARA/VARA Terminal.exe" ;; esac'
export DISPLAY=:0
run bash "$REPO/install-windows-apps.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"VARA Terminal installed."* ]]
grep -q '^wine .*VARA Terminal setup.exe' "$STUB_LOG"
! grep -q '^curl ' "$STUB_LOG"
}
@test "windows apps: a zip saved with underscores for spaces is found too" {
install_all_windows_apps
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
mkdir -p "$HOME/Downloads"
echo "not a zip" > "$HOME/Downloads/VARA_Terminal_v1.2.3.zip"
export DISPLAY=:0
run bash "$REPO/install-windows-apps.sh"
[[ "$output" == *"Using $HOME/Downloads/VARA_Terminal_v1.2.3.zip"* ]]
[ "$status" -eq 1 ]
[[ "$output" == *"VARA Terminal was not installed"* ]]
}
@test "windows apps: without a desktop session, nothing is downloaded and the update isn't failed" {
run bash "$REPO/install-windows-apps.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"without a desktop session"* ]]
! grep -q '^curl ' "$STUB_LOG"
}
@test "windows apps: winetricks runs only once" {
export DISPLAY=:0
mkdir -p "$HOME/.wine"
bash "$REPO/install-windows-apps.sh" || true
bash "$REPO/install-windows-apps.sh" || true
[ "$(grep -c '^winetricks ' "$STUB_LOG")" -eq 1 ]
}
@test "flatpaks: installs missing ones from flathub and records only those" {
local first second
first="$(all_hampack_flatpaks | sed -n 1p)"
second="$(all_hampack_flatpaks | sed -n 2p)"
touch "$FAKE_FLATPAKS/$first"
run bash "$REPO/install-flatpaks.sh"
[ "$status" -eq 0 ]
grep -qx "flatpak install --system --noninteractive flathub $second" "$STUB_LOG"
[ "$(cat "$HAMPACK_STATE/installed-flatpaks")" = "$second" ]
}
@test "flatpaks: update with everything installed installs nothing" {
local pak
for pak in $(all_hampack_flatpaks); do touch "$FAKE_FLATPAKS/$pak"; done
run bash "$REPO/install-flatpaks.sh"
[ "$status" -eq 0 ]
! grep -q '^flatpak install' "$STUB_LOG"
}
@test "patch-potacat removes deb and rpm targets in both forms" {
local pkg="$BATS_TEST_TMPDIR/package.json"
echo '{"build":{"linux":{"target":["AppImage","deb",{"target":"rpm"}],"category":"Utility"}}}' > "$pkg"
run bash "$REPO/patch-potacat.sh" "$pkg"
[ "$status" -eq 0 ]
[ "$(jq -c '.build.linux' "$pkg")" = '{"target":["AppImage"],"category":"Utility"}' ]
}
@test "patch-potacat leaves a package.json without targets alone" {
local pkg="$BATS_TEST_TMPDIR/package.json"
echo '{"name":"x"}' > "$pkg"
run bash "$REPO/patch-potacat.sh" "$pkg"
[ "$status" -eq 0 ]
[ "$(jq -c . "$pkg")" = '{"name":"x"}' ]
}