@@ -134,9 +134,289 @@ jobs:
134134 ./kill-minikube.sh --help || exit 1
135135 ./setup-minikube.sh --help || exit 1
136136 ./setup-env.sh --help || exit 1
137+ ./test-router.sh --help || exit 1
137138
138139 echo "✅ All script help options working"
139140
141+ - name : Test new test utilities
142+ run : |
143+ # Test that test utilities can be sourced without errors
144+ echo "Testing test utilities..."
145+
146+ # Source test utilities and test basic functions
147+ source scripts/test-utils.sh
148+
149+ # Test that functions are available
150+ if ! type test_router_health > /dev/null 2>&1; then
151+ echo "❌ test_router_health function not found"
152+ exit 1
153+ fi
154+
155+ if ! type test_search_products > /dev/null 2>&1; then
156+ echo "❌ test_search_products function not found"
157+ exit 1
158+ fi
159+
160+ if ! type test_router_comprehensive > /dev/null 2>&1; then
161+ echo "❌ test_router_comprehensive function not found"
162+ exit 1
163+ fi
164+
165+ echo "✅ Test utilities functions available"
166+
167+ # Test that test utilities can be run directly
168+ echo "Testing test utilities execution..."
169+
170+ # Test that the script can be run with --help (should show usage)
171+ if ! bash scripts/test-utils.sh --help 2>&1 | \
172+ grep -q "Available tests"; then
173+ echo "❌ test-utils.sh --help not working correctly"
174+ exit 1
175+ fi
176+
177+ echo "✅ Test utilities execution working"
178+
179+ - name : Test script organization
180+ run : |
181+ echo "🔍 Dynamically discovering scripts..."
182+
183+ # Discover user-facing scripts in root directory
184+ echo "📁 Checking user-facing scripts in root directory..."
185+ user_scripts=($(find . -maxdepth 1 -name "*.sh" -type f \
186+ -exec basename {} \; | grep -v "^\.$"))
187+
188+ if [ ${#user_scripts[@]} -eq 0 ]; then
189+ echo "❌ No user-facing scripts found in root directory"
190+ exit 1
191+ fi
192+
193+ echo "✅ Found ${#user_scripts[@]} user-facing scripts:"
194+ for script in "${user_scripts[@]}"; do
195+ echo " - $script"
196+ done
197+
198+ # Discover internal scripts in scripts directory
199+ echo "📁 Checking internal scripts in scripts directory..."
200+ if [ ! -d "scripts" ]; then
201+ echo "❌ scripts directory not found"
202+ exit 1
203+ fi
204+
205+ internal_scripts=($(find scripts -name "*.sh" -type f \
206+ -exec basename {} \;))
207+
208+ if [ ${#internal_scripts[@]} -eq 0 ]; then
209+ echo "❌ No internal scripts found in scripts directory"
210+ exit 1
211+ fi
212+
213+ echo "✅ Found ${#internal_scripts[@]} internal scripts:"
214+ for script in "${internal_scripts[@]}"; do
215+ echo " - scripts/$script"
216+ done
217+
218+ echo "✅ Script organization is correct"
219+
220+ # Test that scripts are using test utilities (no duplication)
221+ echo "Testing for script duplication..."
222+
223+ # Check all scripts for hardcoded curl commands that should use test
224+ # utilities
225+ echo "🔍 Checking for hardcoded curl commands in scripts..."
226+
227+ # Check user-facing scripts
228+ for script in "${user_scripts[@]}"; do
229+ if grep -q "curl.*localhost:4000" "$script"; then
230+ echo "❌ $script contains hardcoded curl commands for router \
231+ testing"
232+ echo " Should use test utilities instead"
233+ exit 1
234+ fi
235+ done
236+
237+ # Check internal scripts (but allow some curl usage in test-utils.sh
238+ # itself)
239+ for script in "${internal_scripts[@]}"; do
240+ if [ "$script" != "test-utils.sh" ] && \
241+ grep -q "curl.*localhost:4000.*health" "scripts/$script"; then
242+ echo "❌ scripts/$script contains hardcoded curl commands for \
243+ health checks"
244+ echo " Should use test utilities instead"
245+ exit 1
246+ fi
247+ done
248+
249+ echo "✅ No duplication found - scripts using test utilities \
250+ correctly"
251+
252+ # Test that test utilities contain expected functions
253+ echo "Testing test utilities content..."
254+
255+ # Check that test-utils.sh exists
256+ if [ ! -f "scripts/test-utils.sh" ]; then
257+ echo "❌ test-utils.sh not found in scripts directory"
258+ exit 1
259+ fi
260+
261+ # Discover test functions dynamically
262+ echo "🔍 Discovering test functions in test-utils.sh..."
263+ test_functions=($(grep -E "^test_[a-zA-Z_]+\(\)" \
264+ scripts/test-utils.sh | sed 's/() {.*//' | sort))
265+
266+ if [ ${#test_functions[@]} -eq 0 ]; then
267+ echo "❌ No test functions found in test-utils.sh"
268+ exit 1
269+ fi
270+
271+ echo "✅ Found ${#test_functions[@]} test functions:"
272+ for func in "${test_functions[@]}"; do
273+ echo " - $func"
274+ done
275+
276+ # Check for essential test functions
277+ essential_functions=("test_router_health" "test_search_products")
278+ for func in "${essential_functions[@]}"; do
279+ if [[ ! " ${test_functions[@]} " =~ " ${func} " ]]; then
280+ echo "❌ Essential test function not found: $func"
281+ exit 1
282+ fi
283+ done
284+
285+ echo "✅ Test utilities contain essential functions"
286+
287+ # Test that test-router.sh works correctly
288+ echo "Testing test-router.sh functionality..."
289+
290+ # Check that test-router.sh exists
291+ if [ ! -f "test-router.sh" ]; then
292+ echo "❌ test-router.sh not found in root directory"
293+ exit 1
294+ fi
295+
296+ # Test that it can show help
297+ if ! ./test-router.sh --help 2>&1 | grep -q "Test Names:"; then
298+ echo "❌ test-router.sh --help not working correctly"
299+ exit 1
300+ fi
301+
302+ # Discover available tests dynamically
303+ echo "🔍 Discovering available tests in test-router.sh..."
304+ available_tests=($(./test-router.sh --help 2>&1 | \
305+ grep -A 20 "Test Names:" | grep -E "^ [a-zA-Z-]+" | \
306+ sed 's/^ //' | sed 's/ .*//' | tr '\n' ' '))
307+
308+ if [ ${#available_tests[@]} -eq 0 ]; then
309+ echo "❌ No tests found in test-router.sh help output"
310+ exit 1
311+ fi
312+
313+ echo "✅ Found ${#available_tests[@]} available tests:"
314+ for test in "${available_tests[@]}"; do
315+ echo " - $test"
316+ done
317+
318+ # Check for essential tests
319+ essential_tests=("health" "products" "status" "all")
320+ for test in "${essential_tests[@]}"; do
321+ if [[ ! " ${available_tests[@]} " =~ " ${test} " ]]; then
322+ echo "❌ Essential test not found: $test"
323+ exit 1
324+ fi
325+ done
326+
327+ echo "✅ test-router.sh functionality working correctly"
328+
329+ # Test that build validation script exists and has help
330+ echo "Testing build validation script..."
331+
332+ # Check if build-validate.sh exists
333+ if [ ! -f "scripts/build-validate.sh" ]; then
334+ echo "❌ build-validate.sh not found in scripts directory"
335+ exit 1
336+ fi
337+
338+ # Test that it has help functionality
339+ if ! ./scripts/build-validate.sh --help 2>&1 | grep -q "Usage:"; then
340+ echo "❌ build-validate.sh --help not working correctly"
341+ exit 1
342+ fi
343+
344+ echo "✅ build-validate.sh exists and has help functionality"
345+
346+ # Test all scripts that have --help functionality
347+ echo "Testing script help functionality..."
348+ echo "🔍 Checking which scripts support --help..."
349+
350+ help_scripts=()
351+ for script in "${user_scripts[@]}"; do
352+ if ./"$script" --help 2>&1 | grep -q "Usage:\|Options:"; then
353+ help_scripts+=("$script")
354+ fi
355+ done
356+
357+ for script in "${internal_scripts[@]}"; do
358+ if ./"scripts/$script" --help 2>&1 | \
359+ grep -q "Usage:\|Options:"; then
360+ help_scripts+=("scripts/$script")
361+ fi
362+ done
363+
364+ if [ ${#help_scripts[@]} -gt 0 ]; then
365+ echo "✅ Found ${#help_scripts[@]} scripts with help \
366+ functionality:"
367+ for script in "${help_scripts[@]}"; do
368+ echo " - $script"
369+ done
370+ else
371+ echo "⚠️ No scripts found with help functionality"
372+ fi
373+
374+ # Test that documentation structure is correct
375+ echo "Testing documentation structure..."
376+
377+ # Check that README.md exists and points to SETUP.md
378+ if ! grep -q "SETUP.md" README.md; then
379+ echo "❌ README.md missing reference to SETUP.md"
380+ exit 1
381+ fi
382+
383+ # Check that SETUP.md exists and contains commands
384+ if [ ! -f "SETUP.md" ]; then
385+ echo "❌ SETUP.md not found"
386+ exit 1
387+ fi
388+
389+ # Check that ARCHITECTURE.md exists
390+ if [ ! -f "ARCHITECTURE.md" ]; then
391+ echo "❌ ARCHITECTURE.md not found"
392+ exit 1
393+ fi
394+
395+ # Check that README-K8S.md is deleted
396+ if [ -f "README-K8S.md" ]; then
397+ echo "❌ README-K8S.md still exists (should be deleted)"
398+ exit 1
399+ fi
400+
401+ echo "✅ Documentation structure is correct"
402+
403+ # Test that cleanup-k8s.sh provides helpful output
404+ echo "Testing cleanup-k8s.sh output..."
405+
406+ # Test that it mentions minikube is still running
407+ if ! ./cleanup-k8s.sh 2>&1 | grep -q "Minikube is still running"; then
408+ echo "❌ cleanup-k8s.sh missing minikube warning"
409+ exit 1
410+ fi
411+
412+ # Test that it mentions kill-minikube.sh
413+ if ! ./cleanup-k8s.sh 2>&1 | grep -q "kill-minikube.sh"; then
414+ echo "❌ cleanup-k8s.sh missing kill-minikube.sh reference"
415+ exit 1
416+ fi
417+
418+ echo "✅ cleanup-k8s.sh provides helpful output"
419+
140420 test-k8s-yaml :
141421 name : Test Kubernetes YAML Format
142422 runs-on : ubuntu-latest
0 commit comments