feat: make install_db.sh's PORT argument optional, defaulting to 3306

This commit is contained in:
Marek Miklewicz
2026-07-05 21:09:20 +02:00
parent 2dd7034558
commit 00dbe93531
2 changed files with 23 additions and 11 deletions
+12 -2
View File
@@ -41,10 +41,20 @@ set -e
[ "$NO_ARGS_STATUS" -eq 2 ] || fail "install_db.sh without arguments should exit with status 2, got $NO_ARGS_STATUS"
printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq 'Użycie:' \
|| fail "install_db.sh without arguments does not print usage"
printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq '<MARIADB_VERSION> <PORT>' \
|| fail "install_db.sh usage does not show required version and port"
printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq '<MARIADB_VERSION> [PORT]' \
|| fail "install_db.sh usage does not show optional port"
if printf '%s\n' "$NO_ARGS_OUTPUT" | grep -Fq 'Ten skrypt musi zostać uruchomiony jako root'; then
fail "install_db.sh without arguments reaches root check instead of usage"
fi
set +e
ONE_ARG_OUTPUT="$("$SCRIPT" 10.11 2>&1)"
ONE_ARG_STATUS=$?
set -e
[ "$ONE_ARG_STATUS" -eq 1 ] \
|| fail "install_db.sh with only a version argument should reach the root check (status 1), got $ONE_ARG_STATUS: $ONE_ARG_OUTPUT"
printf '%s\n' "$ONE_ARG_OUTPUT" | grep -Fq 'Ten skrypt musi zostać uruchomiony jako root' \
|| fail "install_db.sh with only a version argument should default PORT to 3306 and reach the root check, got: $ONE_ARG_OUTPUT"
echo "install_db_cli_test: OK"