init
This commit is contained in:
22
.dev/.mk/test.mk
Normal file
22
.dev/.mk/test.mk
Normal file
@ -0,0 +1,22 @@
|
||||
##@ Test
|
||||
|
||||
DOCKER_COMPOSE := docker compose
|
||||
APP_SERVICE := qrcode-app
|
||||
GO_TEST := $(DOCKER_COMPOSE) exec $(APP_SERVICE) sh -c
|
||||
COVERAGE_FILE := ./tmp/coverage.out
|
||||
EXCLUDE := /internal/view|/vendor|/migrations|/tmp|/build
|
||||
|
||||
.PHONY: test race cover
|
||||
|
||||
test: ## Run tests excluding some directories
|
||||
$(GO_TEST) 'go test -v -count=1 $$(go list ./... | grep -vE "$(EXCLUDE)") | grep -v "\[no test files\]"'
|
||||
|
||||
race: ## Run tests with race detector
|
||||
$(GO_TEST) 'go test -v -race -count=1 ./...'
|
||||
|
||||
cover: ## Run tests with coverage and save HTML report
|
||||
$(GO_TEST) 'mkdir -p ./tmp && \
|
||||
go test -v -short -coverprofile=$(COVERAGE_FILE) ./... && \
|
||||
go tool cover -html=$(COVERAGE_FILE) -o ./tmp/coverage.html && \
|
||||
rm -f $(COVERAGE_FILE)'
|
||||
|
||||
Reference in New Issue
Block a user