23 lines
740 B
Makefile
23 lines
740 B
Makefile
##@ 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)'
|
|
|