1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
# Miscellaneous test checks.
check_dependencies() {
# shellcheck disable=SC2039,3043
local dep missing
missing=""
for dep in "$@"; do
if ! command -v "$dep" > /dev/null 2>&1; then
[ "$missing" ] && missing="$missing $dep" || missing="$dep"
fi
done
if [ "$missing" ]; then
echo "Missing dependencies: $missing" >&2
exit 1
fi
}
check_empty() {
if [ "$(find "${1}" 2> /dev/null | wc -l)" -gt "1" ]; then
echo "${1} is not empty, content:"
find "${1}"
false
fi
}
check_empty_table() {
# The profiles table will never be empty since the `default` profile cannot
# be deleted.
if [ "$2" = 'profiles' ]; then
if [ -n "$(sqlite3 "${1}" "SELECT * FROM ${2} WHERE name != 'default';")" ]; then
echo "DB table ${2} is not empty, content:"
sqlite3 "${1}" "SELECT * FROM ${2} WHERE name != 'default';"
return 1
fi
return 0
fi
if [ -n "$(sqlite3 "${1}" "SELECT * FROM ${2};")" ]; then
echo "DB table ${2} is not empty, content:"
sqlite3 "${1}" "SELECT * FROM ${2};"
return 1
fi
}
|