-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (33 loc) · 1.35 KB
/
Makefile
File metadata and controls
41 lines (33 loc) · 1.35 KB
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
.PHONY: test test-unit test-integration test-coverage clean test-deps-start test-deps-stop test-deps-wait
test:
go test -race -p 1 ./...
test-unit:
go test -race -short ./engine/... ./www/... ./runner/...
test-integration: test-deps-start test-deps-wait
POSTGRES_PASSWORD=postgres go test -race ./tests/integration/... -timeout 10m
@$(MAKE) test-deps-stop
test-deps-start:
@docker ps -q -f name=quotient-test-postgres | grep -q . || \
docker run -d --name quotient-test-postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=quotient_test \
-p 5432:5432 \
postgres:16-alpine
@docker ps -q -f name=quotient-test-redis | grep -q . || \
docker run -d --name quotient-test-redis \
-p 6379:6379 \
redis:7-alpine
test-deps-wait:
@echo "Waiting for Postgres..."
@until docker exec quotient-test-postgres pg_isready -U postgres > /dev/null 2>&1; do sleep 1; done
@echo "Waiting for Redis..."
@until docker exec quotient-test-redis redis-cli ping > /dev/null 2>&1; do sleep 1; done
@echo "Services ready."
test-deps-stop:
@docker stop quotient-test-postgres quotient-test-redis 2>/dev/null || true
@docker rm quotient-test-postgres quotient-test-redis 2>/dev/null || true
test-coverage:
go test -race -p 1 -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
clean: test-deps-stop
rm -f coverage.out coverage.html