refactor: move stack assets and wire in mailhog
This commit is contained in:
50
SupportStack/output/tests/test_mailhog.sh
Executable file
50
SupportStack/output/tests/test_mailhog.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Unit test for Mailhog component
|
||||
# TDD flow: test first to ensure failure prior to implementation
|
||||
|
||||
set -e
|
||||
|
||||
# Load environment settings
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ENV_FILE="${SCRIPT_DIR}/TSYSDevStack-SupportStack-Demo-Settings"
|
||||
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "Error: Environment settings file not found at $ENV_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "$ENV_FILE"
|
||||
|
||||
echo "Testing Mailhog availability and functionality..."
|
||||
|
||||
# Ensure Mailhog container is running
|
||||
if ! docker ps | grep -q "$MAILHOG_NAME"; then
|
||||
echo "❌ Mailhog container is not running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Allow service time to respond
|
||||
sleep 3
|
||||
|
||||
# Verify Mailhog UI is reachable
|
||||
if curl -f -s "http://${BIND_ADDRESS}:${MAILHOG_UI_PORT}/" > /dev/null 2>&1; then
|
||||
echo "✅ Mailhog UI is accessible at http://${BIND_ADDRESS}:${MAILHOG_UI_PORT}"
|
||||
else
|
||||
echo "❌ Mailhog UI is not accessible at http://${BIND_ADDRESS}:${MAILHOG_UI_PORT}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Optional SMTP port check (basic TCP connect)
|
||||
if command -v nc >/dev/null 2>&1; then
|
||||
if timeout 3 nc -z "${BIND_ADDRESS}" "${MAILHOG_SMTP_PORT}" >/dev/null 2>&1; then
|
||||
echo "✅ Mailhog SMTP port ${MAILHOG_SMTP_PORT} is reachable"
|
||||
else
|
||||
echo "⚠️ Mailhog SMTP port ${MAILHOG_SMTP_PORT} not reachable (informational)"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ nc command not available; skipping SMTP connectivity check"
|
||||
fi
|
||||
|
||||
echo "✅ Mailhog component test passed"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user