-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests-local.sh
More file actions
executable file
·40 lines (31 loc) · 1.15 KB
/
run-tests-local.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
script_dir=$(dirname "$(realpath -s "$0")")
coverage() {
temp_path="$script_dir/coverage.out"
report_dir="$script_dir/.coverage"
report_filename="report.html"
report_path="$report_dir/$report_filename"
export PAYLOAD_STORAGE_PATH=testdata/.out/json
export MYSQL_HOST=127.0.0.1
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=password
export MYSQL_DATABASE=mailculator
export MYSQL_TLS=false
go mod tidy
go test ./... -coverpkg=./... -coverprofile=$temp_path
cov=$(go tool cover -func $temp_path | grep -E "^total" | grep -o -E "[0-9]*\.[0-9]*%$")
echo "Total coverage: ${cov}"
mkdir -p $report_dir
go tool cover -html=$temp_path -o $report_path
echo "Report exported at $report_path"
rm $temp_path
}
if ! docker compose -f "$script_dir/compose.yml" --profile test-deps up -d --build --force-recreate; then
echo "Could not start test dependencies"
docker compose -f "$script_dir/compose.yml" --profile test-deps down --remove-orphans
exit 1
fi
# run in subshell to avoid exporting env variables
(coverage)
docker compose -f "$script_dir/compose.yml" --profile test-deps down --remove-orphans