-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (46 loc) · 1.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
ifeq ($(POSTGRES_SETUP_TEST),)
POSTGRES_SETUP_TEST := user=postgres password=test dbname=test host=localhost port=5432 sslmode=disable
endif
export DB_NAME=test
export DB_PASSWORD=test
export DB_HOST=localhost
export DB_USER=postgres
export DB_PORT=5432
POSTGRES_CONTAINER_NAME = postgres_test
DOCKER_COMPOSE_FILE = docker-compose.yaml
INTERNAL_PKG_PATH=$(CURDIR)/internal/repository
MIGRATION_FOLDER=$(INTERNAL_PKG_PATH)/migrations
.PHONY: run-jaeger
run-jaeger:
docker run -d -p 6831:6831/udp -p 16686:16686 jaegertracing/all-in-one:latest
.PHONY: start-test-environment
start-test-environment:
docker-compose -f $(DOCKER_COMPOSE_FILE) up -d
.PHONY: stop-test-environment
stop-test-environment:
docker-compose -f $(DOCKER_COMPOSE_FILE) down
.PHONY: integration-test
integration-test: start-test-environment
go test -tags integration ./...
.PHONY: integration-test-cover
integration-test-cover:
go test -tags integration ./... -cover
.PHONY: unit-test
unit-test:
go test ./... -cover
.PHONY: migration-create
migration-create:
goose -dir "$(MIGRATION_FOLDER)" create "$(name)" sql
.PHONY: test-migration-up
test-migration-up:
goose -dir "$(MIGRATION_FOLDER)" postgres "$(POSTGRES_SETUP_TEST)" up
.PHONY: test-migration-down
test-migration-down:
goose -dir "$(MIGRATION_FOLDER)" postgres "$(POSTGRES_SETUP_TEST)" down
.PHONY: clean-test-data
clean-test-data:
docker exec $(POSTGRES_CONTAINER_NAME) psql -U postgres -d test -c "TRUNCATE table_name RESTART IDENTITY;"
.PHONY: run-tests
run-tests: unit-test integration-test stop-test-environment
.PHONY: all
all: run-tests