-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (55 loc) · 1.86 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
ifeq ($(POSTGRES_SETUP_TEST),)
POSTGRES_SETUP_TEST := user=postgres password=1111 dbname=TestAvito host=localhost port=5433 sslmode=disable
endif
ifeq ($(POSTGRES_SETUP),)
# POSTGRES_SETUP := user=postgres password=1111 dbname=Avito host=db port=5432 sslmode=disable
POSTGRES_SETUP := user=postgres password=1111 dbname=Avito host=localhost port=5432 sslmode=disable
endif
INTERNAL_PKG_PATH=$(CURDIR)/internal/storage
MIGRATION_FOLDER=$(INTERNAL_PKG_PATH)/db/migrations
MOCKGEN_TAG=1.2.0
DOCKER_COMPOSE_FILE := docker-compose.yml
.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)" up
.PHONY: test-migration-down
test-migration-down:
goose -dir "$(MIGRATION_FOLDER)" postgres "$(POSTGRES_SETUP)" down
.PHONY: test-migration-test-up
test-migration-test-up:
goose -dir "$(MIGRATION_FOLDER)" postgres "$(POSTGRES_SETUP_TEST)" up
.PHONY: test-migration-test-down
test-migration-test-down:
goose -dir "$(MIGRATION_FOLDER)" postgres "$(POSTGRES_SETUP_TEST)" down
.PHONY: .generate-mockgen-deps
.generate-mockgen-deps:
ifeq ($(wildcard $(MOCKGEN_BIN)),)
@GOBIN=$(LOCAL_BIN) go install github.com/golang/mock/mockgen@$(MOCKGEN_TAG)
endif
.PHONY: .generate-mockgen
.generate-mockgen:
PATH="$(LOCAL_BIN):$$PATH" go generate -x -run=mockgen ./...
.PHONY: gofmt
gofmt:
goimports -l -w $(CURDIR)
.test:
$(info Running tests...)
go test ./...
.PHONY: integration-test
integration-test:
go test -tags=integration -v ./tests
.PHONY: unit-test
unit-test:
go test -v ./...
.PHONY: unit-test-coverage
unit-test-coverage:
go test -v ./... -coverprofile=coverage.out
.PHONY: docker-up
docker-up:
@docker-compose -f $(DOCKER_COMPOSE_FILE) up -d
.PHONY: docker-down
docker-down:
@docker-compose -f $(DOCKER_COMPOSE_FILE) down