Skip to content

Commit

Permalink
test: add certgenerator ut, exclude more pkg for make cover (#651)
Browse files Browse the repository at this point in the history
## What type of PR is this?

/kind test

## What this PR does / why we need it:

This PR adds unit tests for the certgenerator module and excludes more
packages from the make cover command to improve code coverage analysis.

## Which issue(s) this PR fixes:

Fixes #
  • Loading branch information
elliotxx authored Nov 25, 2024
1 parent 7220e4a commit 0706882
Show file tree
Hide file tree
Showing 5 changed files with 1,263 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gen-version: ## Generate version file
.PHONY: test
test: ## Run the tests
@PKG_LIST=$${TARGET_PKG:-$(GOSOURCE_PATHS)}; \
go test -gcflags=all=-l -timeout=10m `go list -e $${PKG_LIST} | grep -vE "cmd|internal|internalimport|generated|handler|registry|openapi|apis"` ${TEST_FLAGS}
go test -gcflags=all=-l -timeout=10m `go list -e $${PKG_LIST} | grep -vE "cmd|internal|internalimport|generated|handler|middleware|registry|openapi|apis|version|gitutil|server|elasticsearch"` ${TEST_FLAGS}


# cover: Generates a coverage report for the specified TARGET_PKG or default GOSOURCE_PATHS.
Expand All @@ -53,7 +53,7 @@ test: ## Run the tests
cover: ## Generates coverage report
@PKG_LIST=$${TARGET_PKG:-$(GOSOURCE_PATHS)}; \
echo "🚀 Executing unit tests for $${PKG_LIST}:"; \
go test -gcflags=all=-l -timeout=10m `go list $${PKG_LIST} | grep -vE "cmd|internal|internalimport|generated|handler|registry|openapi|apis"` -coverprofile $(COVERAGEOUT) ${TEST_FLAGS} && \
go test -gcflags=all=-l -timeout=10m `go list $${PKG_LIST} | grep -vE "cmd|internal|internalimport|generated|handler|middleware|registry|openapi|apis|version|gitutil|server|elasticsearch"` -coverprofile $(COVERAGEOUT) ${TEST_FLAGS} && \
(echo "\n📊 Calculating coverage rate:"; go tool cover -func=$(COVERAGEOUT)) || (echo "\n💥 Running go test failed!"; exit 1)


Expand Down
Loading

0 comments on commit 0706882

Please sign in to comment.