Adds compulsory test coverage, fix tests

This commit is contained in:
Jamie Curnow
2024-05-07 21:21:30 +10:00
parent 6da020aab1
commit be0ce673ff
12 changed files with 178 additions and 63 deletions

View File

@ -1,7 +1,23 @@
#!/bin/bash -e
#!/bin/bash
set -eu
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
go test -json -cover -coverprofile="$DIR/../coverage.out" ./internal/... | tparse
go tool cover -html="$DIR/../coverage.out" -o "$DIR/../coverage.html"
rm -f "$DIR/../coverage.out"
if ! command -v go-test-coverage &>/dev/null; then
go install github.com/vladopajic/go-test-coverage/v2@latest
fi
if ! command -v tparse &>/dev/null; then
go install github.com/mfridman/tparse@latest
fi
rm -f "$DIR/coverage.html"
trap cleanup EXIT
cleanup() {
rm -f "$DIR/coverage.out"
}
echo "Running go test suite ..."
go test -json -cover ./... -coverprofile="$DIR/coverage.out" | tparse
go tool cover -html="$DIR/coverage.out" -o "$DIR/coverage.html"
go-test-coverage -c "$DIR/.testcoverage.yml"