From a99892389efefd9a1ba3f5a79ba0c35d08f6ac0a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 15 May 2026 20:20:59 +0000 Subject: [PATCH] test: Add standalone test for mermaid invalid USERNAME validation Added `test/_global/mermaid_invalid_user.sh` to explicitly test the error path in `src/mermaid/install.sh` when an invalid `USERNAME` format is provided. This test script runs the install script directly with a bad username and asserts the script fails with the expected error output. Co-authored-by: MiguelRodo <23501332+MiguelRodo@users.noreply.github.com> --- test/_global/mermaid_invalid_user.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 test/_global/mermaid_invalid_user.sh diff --git a/test/_global/mermaid_invalid_user.sh b/test/_global/mermaid_invalid_user.sh new file mode 100755 index 0000000..99dd7be --- /dev/null +++ b/test/_global/mermaid_invalid_user.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +# SCRIPT_DIR is the directory of this script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +INSTALL_SCRIPT="$SCRIPT_DIR/../../src/mermaid/install.sh" + +echo "Testing invalid USERNAME..." +output=$(USERNAME="-invalid" bash "$INSTALL_SCRIPT" 2>&1 || true) + +if echo "$output" | grep -q "Error: Invalid USERNAME"; then + echo "✅ Success: Caught invalid username" + exit 0 +else + echo "❌ Fail: Did not catch invalid username" + echo "Output was: $output" + exit 1 +fi