#!/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' } 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"* ]] [[ "$output" == *"VARA Terminal was not installed"* ]] grep -q "^curl .*VARA%20Products" "$STUB_LOG" } @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"}' ] }