@@ -26,38 +26,69 @@ echo -e "${CYAN} Module: ${MODULE}${NC}"
2626echo -e " ${CYAN} ======================================${NC} "
2727echo " "
2828
29+ SNIPEIT_URL=" http://localhost:8401"
30+ NO_CLEANUP=${NO_CLEANUP:- 0}
31+
32+ cleanup () {
33+ if [ " ${NO_CLEANUP} " = " 1" ]; then
34+ info " NO_CLEANUP=1 — skipping teardown"
35+ else
36+ info " Phase 4: Cleanup"
37+ docker compose -f " ${COMPOSE_FILE} " down -v --remove-orphans 2> /dev/null || true
38+ info " Cleanup complete"
39+ fi
40+ }
41+ trap cleanup EXIT
42+
43+ section () { echo -e " \n${CYAN} ## $1 ${NC} " ; }
44+
2945# ── PHASE 1: Setup ────────────────────────────────────────────────────────────
30- info " Phase 1: Setup"
46+ section " Phase 1: Setup"
3147docker compose -f " ${COMPOSE_FILE} " up -d
32- info " Waiting 30s for ${MODULE} to initialize..."
33- sleep 30
48+ info " Waiting 120s for Snipe-IT to initialize (MariaDB + Laravel seed) ..."
49+ sleep 120
3450
3551# ── PHASE 2: Health Checks ────────────────────────────────────────────────────
36- info " Phase 2: Health Checks"
52+ section " Phase 2: Health Checks"
53+
54+ if docker compose -f " ${COMPOSE_FILE} " ps snipeit-s01-db 2> /dev/null | grep -q ' Up\|running' ; then
55+ pass " 2.1 MariaDB (snipeit-s01-db) is up"
56+ else
57+ fail " 2.1 MariaDB is not running"
58+ fi
3759
38- if docker compose -f " ${COMPOSE_FILE} " ps | grep -q " running\|Up " ; then
39- pass " Container is running "
60+ if docker compose -f " ${COMPOSE_FILE} " ps snipeit-s01-app 2> /dev/null | grep -q ' Up\|running ' ; then
61+ pass " 2.2 Snipe-IT app (snipeit-s01-app) is up "
4062else
41- fail " Container is not running"
63+ fail " 2.2 Snipe-IT app is not running"
4264fi
4365
4466# ── PHASE 3: Functional Tests ─────────────────────────────────────────────────
45- info " Phase 3: Functional Tests (Lab 01 — Standalone)"
46-
47- # TODO: Add module-specific functional tests here
48- # Example:
49- # if curl -sf http://localhost:80/health > /dev/null 2>&1; then
50- # pass "Health endpoint responds"
51- # else
52- # fail "Health endpoint not reachable"
53- # fi
54-
55- warn " Functional tests for Lab 16-01 pending implementation"
56-
57- # ── PHASE 4: Cleanup ──────────────────────────────────────────────────────────
58- info " Phase 4: Cleanup"
59- docker compose -f " ${COMPOSE_FILE} " down -v --remove-orphans
60- info " Cleanup complete"
67+ section " Phase 3: Functional Tests"
68+
69+ # 3.1 Root URL responds
70+ HTTP_CODE=$( curl -o /dev/null -sw ' %{http_code}' -L " ${SNIPEIT_URL} /" 2> /dev/null || echo 000)
71+ if echo " ${HTTP_CODE} " | grep -q ' ^[23]' ; then
72+ pass " 3.1 Snipe-IT web UI accessible (HTTP ${HTTP_CODE} )"
73+ else
74+ fail " 3.1 Snipe-IT web UI not accessible (HTTP ${HTTP_CODE} )"
75+ fi
76+
77+ # 3.2 Response contains recognizable Snipe-IT content
78+ RESPONSE=$( curl -sfL " ${SNIPEIT_URL} /" 2> /dev/null || echo ' ' )
79+ if echo " ${RESPONSE} " | grep -qi ' snipe\|laravel\|login\|asset' ; then
80+ pass " 3.2 Response contains Snipe-IT application content"
81+ else
82+ warn " 3.2 Could not confirm Snipe-IT content in response (app may still be starting)"
83+ fi
84+
85+ # 3.3 Health endpoint
86+ HTTP_HEALTH=$( curl -o /dev/null -sw ' %{http_code}' " ${SNIPEIT_URL} /health" 2> /dev/null || echo 000)
87+ if echo " ${HTTP_HEALTH} " | grep -q ' ^[23]' ; then
88+ pass " 3.3 Health endpoint responds (HTTP ${HTTP_HEALTH} )"
89+ else
90+ warn " 3.3 Health endpoint not available (HTTP ${HTTP_HEALTH} ) — may not be implemented"
91+ fi
6192
6293# ── Results ───────────────────────────────────────────────────────────────────
6394echo " "
0 commit comments