This commit is contained in:
@@ -22,6 +22,10 @@ setup() {
|
||||
stub pacman 'grep "^$2 " <<< "$INSTALLED" || exit 1'
|
||||
stub checkupdates 'printf "%s" "$PENDING"; [ -n "$PENDING" ] || exit 2'
|
||||
export INSTALLED="mesa 1:26.2.6-1" PENDING=""
|
||||
# The mirror synced $SYNCED_HOURS ago (an hour by default)
|
||||
export MIRRORLIST="$BATS_TEST_TMPDIR/mirrorlist" SYNCED_HOURS=1
|
||||
echo 'Server = https://mirror.example/archlinux/$repo/os/$arch' > "$MIRRORLIST"
|
||||
stub curl 'echo "$(( $(date +%s) - SYNCED_HOURS * 3600 ))"'
|
||||
}
|
||||
|
||||
@test "version shows the kernel and Mesa, with nothing newer to install" {
|
||||
@@ -31,6 +35,7 @@ setup() {
|
||||
[[ "$output" == *"Kernel 9.9.1-arch1-1 (newer kernel installed, reboot to use it)"$'\n'* ]]
|
||||
[[ "$output" == *"Video driver Mesa 26.2.6"$'\n'* ]]
|
||||
[[ "$output" != *"is available"* ]]
|
||||
[[ "$output" != *"mirror"* ]]
|
||||
}
|
||||
|
||||
@test "version suggests update for a newer kernel and video driver" {
|
||||
@@ -68,3 +73,19 @@ setup() {
|
||||
[[ "$output" == *"Kernel 9.9.1-arch1-1"* ]]
|
||||
[[ "$output" != *"is available"* ]]
|
||||
}
|
||||
|
||||
@test "version warns when the package mirror is behind Arch" {
|
||||
export SYNCED_HOURS=73
|
||||
run bash "$CD/version"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"Your package mirror (https://mirror.example/archlinux) last synced with Arch 3 days ago"* ]]
|
||||
[[ "$output" == *"Run update"* ]]
|
||||
}
|
||||
|
||||
@test "version doesn't warn about a mirror it can't reach" {
|
||||
rm "$STUB_BIN/curl"
|
||||
stub curl 'exit 7'
|
||||
run bash "$CD/version"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" != *"mirror"* ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user