-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (44 loc) · 1.61 KB
/
Makefile
File metadata and controls
56 lines (44 loc) · 1.61 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
.PHONY: test test-unit test-integration test-integration-ci consul-up consul-down build clean
# Default target
all: test build
# Build the binary
build:
go build -o tagit .
# Run all tests (unit only by default)
test: test-unit
# Run unit tests
test-unit:
go test -race ./...
# Run integration tests (requires Consul running)
test-integration:
go test -race -tags=integration ./...
# Start Consul for local integration testing
consul-up:
docker compose -f docker-compose.test.yml up -d
@echo "Waiting for Consul to be ready..."
@until docker compose -f docker-compose.test.yml exec -T consul consul members >/dev/null 2>&1; do \
sleep 1; \
done
@echo "Consul is ready"
# Stop Consul
consul-down:
docker compose -f docker-compose.test.yml down -v
# Run integration tests with Consul lifecycle management (for CI)
test-integration-ci: consul-up
@echo "Running integration tests..."
go test -race -tags=integration ./... || (docker compose -f docker-compose.test.yml down -v && exit 1)
docker compose -f docker-compose.test.yml down -v
# Run all tests including integration (local development)
test-all: consul-up
go test -race -tags=integration ./...
docker compose -f docker-compose.test.yml down -v
# Coverage with integration tests
coverage:
go test -coverpkg=./... ./... -race -coverprofile=coverage.out -covermode=atomic
coverage-integration: consul-up
go test -coverpkg=./... -tags=integration ./... -race -coverprofile=coverage.out -covermode=atomic
docker compose -f docker-compose.test.yml down -v
# Clean up
clean:
rm -f tagit coverage.out
docker compose -f docker-compose.test.yml down -v 2>/dev/null || true