1
0
mirror of https://github.com/goharbor/harbor.git synced 2024-12-23 00:57:44 +01:00
harbor/tests/coverage4gotest.sh
Steven Zou 24c0be789d Add more UT cases for changed chart API
- add more cases in the ChartRepositoryAPI controller
- move chart utility testing functions to a separate go file under testing
- ignore testing coverage for testing folder
- update other UT cases to reflect the change of adding chart testing utility functions

Signed-off-by: Steven Zou <szou@vmware.com>
2018-09-20 17:51:27 +08:00

37 lines
766 B
Bash
Executable File

#!/bin/bash
set -e
echo "mode: set" >>profile.cov
deps=""
# listDeps lists packages referenced by package in $1,
# excluding golang standard library and packages in
# direcotry vendor
function listDeps(){
pkg=$1
deps=$pkg
ds=$(echo $(go list -f '{{.Imports}}' $pkg) | sed 's/[][]//g')
for d in $ds
do
if echo $d | grep -q "github.com/goharbor/harbor" && echo $d | grep -qv "vendor"
then
deps="$deps,$d"
fi
done
}
packages=$(go list ./... | grep -v -E 'vendor|tests|testing')
for package in $packages
do
listDeps $package
# echo "DEBUG: testing package $package"
go test -race -cover -coverprofile=profile.tmp -coverpkg "$deps" $package
if [ -f profile.tmp ]
then
cat profile.tmp | tail -n +2 >> profile.cov
rm profile.tmp
fi
done