1+ #! /bin/bash
2+ # Create temporary directory for coverage files
3+ TEMP_DIR=$( mktemp -d)
4+ trap ' rm -rf "$TEMP_DIR"' EXIT
5+
16go mod tidy
27cd health
3- go test -v
8+ # Run health tests with coverage
9+ go test -v -cover -coverprofile=" $TEMP_DIR /health.out"
10+ HEALTH_EXIT=$?
411npx kill-port 8090
512cd ../verify
6- npm install -g firebase-tools
7- if (firebase --project=" test" emulators:exec " go test" ); then
8- echo " Exited Success"
9- else
13+ # Use npx instead of global installation
14+ npx firebase-tools --project=" test" emulators:exec " go test -v -cover -coverprofile=\" $TEMP_DIR /verify.out\" " --timeout=60s || {
15+ echo " Firebase test exited with error or timed out"
1016 exit 1
11- fi
12- npx kill-port 8090
17+ }
18+ echo " Exited Success"
19+ npx kill-port 8090
20+
21+ # Display coverage reports in console
22+ cd ..
23+ echo " ================================"
24+ echo " COVERAGE REPORTS"
25+ echo " ================================"
26+ echo " Health module coverage:"
27+ go tool cover -func=" $TEMP_DIR /health.out"
28+ echo " ================================"
29+ echo " Verify module coverage:"
30+ go tool cover -func=" $TEMP_DIR /verify.out"
31+ echo " ================================"
32+
33+ # Display total coverage
34+ echo " Combined coverage:"
35+ echo " mode: set" > " $TEMP_DIR /all.out"
36+ tail -n +2 -q " $TEMP_DIR /health.out" " $TEMP_DIR /verify.out" >> " $TEMP_DIR /all.out" 2> /dev/null
37+ go tool cover -func=" $TEMP_DIR /all.out"
38+ echo " ================================"
39+
40+ # Exit with proper exit code
41+ [ $HEALTH_EXIT -ne 0 ] && exit $HEALTH_EXIT
42+ exit 0
0 commit comments