Add bats test suite
Black-box tests that run the script with stub commands on a minimal PATH and temp config/state folders.
This commit is contained in:
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# "aur repo -u -d <repo>": prints $STUB_DATA/aur, exits $AUR_RC (default 0).
|
||||
printf '%s %s\n' "${0##*/}" "$*" >> "$STUB_DATA/calls"
|
||||
[[ ${1:-} == repo ]] || exit 1
|
||||
if [[ -s $STUB_DATA/aur ]]; then
|
||||
printf '%s\n' "$(<"$STUB_DATA/aur")"
|
||||
fi
|
||||
exit "${AUR_RC:-0}"
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# Prints $STUB_DATA/checkupdates; exits $CHECKUPDATES_RC, else 0 with updates and 2 without, like the real one.
|
||||
printf '%s %s\n' "${0##*/}" "$*" >> "$STUB_DATA/calls"
|
||||
if [[ -s $STUB_DATA/checkupdates ]]; then
|
||||
printf '%s\n' "$(<"$STUB_DATA/checkupdates")"
|
||||
exit "${CHECKUPDATES_RC:-0}"
|
||||
fi
|
||||
exit "${CHECKUPDATES_RC:-2}"
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Exits $FWUPD_RC: 0 = firmware updates available, 2 (default) = none.
|
||||
printf '%s %s\n' "${0##*/}" "$*" >> "$STUB_DATA/calls"
|
||||
exit "${FWUPD_RC:-2}"
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
# Only needs to exist: the script checks for it with command -v.
|
||||
exit 0
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Appends the title, the body and a "--" line to $STUB_DATA/notify; exits $NOTIFY_RC (default 0).
|
||||
printf '%s\n' "$1" "$2" -- >> "$STUB_DATA/notify"
|
||||
exit "${NOTIFY_RC:-0}"
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# "pacdiff -o": prints $STUB_DATA/pacdiff.
|
||||
printf '%s %s\n' "${0##*/}" "$*" >> "$STUB_DATA/calls"
|
||||
[[ ${1:-} == -o ]] || exit 1
|
||||
if [[ -s $STUB_DATA/pacdiff ]]; then
|
||||
printf '%s\n' "$(<"$STUB_DATA/pacdiff")"
|
||||
fi
|
||||
exit 0
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
# "pacman -Q <pkg>": looks the package up in $STUB_DATA/installed ("name version" lines).
|
||||
[[ ${1:-} == -Q && $# == 2 ]] || { echo "pacman stub: unsupported arguments: $*" >&2; exit 1; }
|
||||
if [[ -f $STUB_DATA/installed ]]; then
|
||||
while read -r name ver; do
|
||||
if [[ $name == "$2" ]]; then
|
||||
printf '%s %s\n' "$name" "$ver"
|
||||
exit 0
|
||||
fi
|
||||
done < "$STUB_DATA/installed"
|
||||
fi
|
||||
printf "error: package '%s' was not found\n" "$2" >&2
|
||||
exit 1
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
# "uname -r": prints $STUB_KERNEL.
|
||||
printf '%s\n' "$STUB_KERNEL"
|
||||
Reference in New Issue
Block a user