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
+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
|
||||
Reference in New Issue
Block a user