Skip to content

Commit

Permalink
feat add coverage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed Jan 9, 2020
1 parent 163a820 commit d7a72f7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ docs/book/book/
# skip bin
bin/*

# skip .out files (coverage tests)
*.out

# skip testdata gopath non-src
/testdata/gopath/bin
/testdata/gopath/pkg
Expand Down
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ script:
- ./test.sh
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then PATH=$PATH:$(pwd) ./test_e2e.sh; fi

jobs:
include:
- stage: Go Coverage
before_script:
# The following module is used to integrate the projct with coveralls.io. It allow us to easily sent the data.
# More info: https://github.com/mattn/goveralls
- go get github.com/mattn/goveralls@v0.0.4
script:
- make test-coverage
- $GOPATH/bin/goveralls -service=travis-ci -coverprofile=coverage-all.out -repotoken=$COVERALLS_TOKEN

# TBD. Suppressing for now.
notifications:
email: false
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ test-ci: ## Run the unit tests (used in the CI)
.PHONY: test-e2e
test-e2e: ## Run the integration tests (used in the CI)
./test_e2e.sh

.PHONY: test-coverage
test-coverage: ## Run coveralls
# remove all coverage files if exists
- rm -rf *.out
# run the go test for each covered go file and then, add its result to coverage-all.out file
go test -failfast -tags=integration -coverprofile=coverage-all.out -covermode=count ./pkg/... ./cmd/...
2 changes: 1 addition & 1 deletion testdata/project-v2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ vet:

# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Build the docker image
docker-build: test
Expand Down

0 comments on commit d7a72f7

Please sign in to comment.