Files
Coredesktop-Dev/tests/update.bats
T
davidandClaude Opus 5.5 2207208326 Install QEMU's virtio-vga display and check for it
The smoketest VMs start with -vga virtio, but Arch packages that display
apart from qemu-base, so the base image build failed with "Virtio VGA not
available". update.sh now installs qemu-hw-display-virtio-vga, and doctor
and smoketest run check QEMU has the display before anything downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:04:39 -07:00

52 lines
1.7 KiB
Bash

#!/usr/bin/env bats
load test_helper
HOOK_MARKER="# Installed by coredesktop-dev; remove with: coredesktop-dev hooks remove"
@test "update installs the packages and links the command, without asking anything" {
run bash "$PROJECT/update.sh" < /dev/null
[ "$status" -eq 0 ]
called install_packages shellcheck bats tea qemu-base qemu-hw-display-virtio-vga libisoburn
[ "$(readlink "$HOME/.local/bin/coredesktop-dev")" = "$PROJECT/bin/coredesktop-dev" ]
}
@test "update fixes a link that points somewhere else" {
mkdir -p "$HOME/.local/bin"
ln -s /nowhere "$HOME/.local/bin/coredesktop-dev"
run bash "$PROJECT/update.sh" < /dev/null
[ "$status" -eq 0 ]
[ "$(readlink "$HOME/.local/bin/coredesktop-dev")" = "$PROJECT/bin/coredesktop-dev" ]
}
@test "update leaves an unchanged pre-push hook alone" {
make_working_copy
cp "$PROJECT/hooks/pre-push" "$WC/.git/hooks/pre-push"
touch -d '2020-01-01' "$WC/.git/hooks/pre-push"
run bash "$PROJECT/update.sh" < /dev/null
[ "$status" -eq 0 ]
[ "$(date -r "$WC/.git/hooks/pre-push" +%Y)" = 2020 ]
[[ "$output" != *"Updated the pre-push hook"* ]]
}
@test "update refreshes our pre-push hook when it has changed" {
make_working_copy
printf '%s\n' '#!/bin/bash' "$HOOK_MARKER" 'old version' > "$WC/.git/hooks/pre-push"
run bash "$PROJECT/update.sh" < /dev/null
[ "$status" -eq 0 ]
cmp "$PROJECT/hooks/pre-push" "$WC/.git/hooks/pre-push"
[[ "$output" == *"Updated the pre-push hook"* ]]
}
@test "update doesn't touch someone else's pre-push hook" {
make_working_copy
printf '%s\n' '#!/bin/bash' 'mine' > "$WC/.git/hooks/pre-push"
run bash "$PROJECT/update.sh" < /dev/null
[ "$status" -eq 0 ]
[ "$(tail -n 1 "$WC/.git/hooks/pre-push")" = mine ]
}