|
1 | | -.PHONY: help build test test-unit test-integration test-endpoints test-publish test-all lint lint-fix validate validate-schemas validate-examples check dev-compose clean publisher generate-schema check-schema |
| 1 | +.PHONY: help build test test-unit test-unit-verbose test-integration test-endpoints test-publish test-all lint lint-fix validate validate-schemas validate-examples check dev-compose clean publisher generate-schema check-schema |
2 | 2 |
|
3 | 3 | # Default target |
4 | 4 | help: ## Show this help message |
@@ -28,15 +28,36 @@ check-schema: ## Check if server.schema.json is in sync with openapi.yaml |
28 | 28 | # Test targets |
29 | 29 | test-unit: ## Run unit tests with coverage (requires PostgreSQL) |
30 | 30 | @echo "Starting PostgreSQL for unit tests..." |
31 | | - @docker compose up -d postgres |
| 31 | + @docker compose up -d postgres 2>&1 | grep -v "Pulling\|Pulled\|Creating\|Created\|Starting\|Started" || true |
32 | 32 | @echo "Waiting for PostgreSQL to be ready..." |
33 | 33 | @sleep 3 |
| 34 | + @echo "" |
34 | 35 | @echo "Running unit tests..." |
35 | | - go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/... |
36 | | - go tool cover -html=coverage.out -o coverage.html |
37 | | - @echo "Coverage report generated: coverage.html" |
38 | | - @echo "Stopping PostgreSQL..." |
39 | | - @docker compose down postgres |
| 36 | + @if command -v gotestsum >/dev/null 2>&1; then \ |
| 37 | + gotestsum --format pkgname-and-test-fails -- -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/... 2>&1 | grep -v "ld: warning:"; \ |
| 38 | + else \ |
| 39 | + go test -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/... 2>&1 | grep -v "ld: warning:" | grep -v "^ld:"; \ |
| 40 | + fi |
| 41 | + @echo "" |
| 42 | + @go tool cover -html=coverage.out -o coverage.html |
| 43 | + @echo "✅ Coverage report: coverage.html" |
| 44 | + @go tool cover -func=coverage.out | tail -1 |
| 45 | + @echo "" |
| 46 | + @docker compose down postgres >/dev/null 2>&1 |
| 47 | + @echo "✅ Tests complete" |
| 48 | + |
| 49 | +test-unit-verbose: ## Run unit tests with verbose output |
| 50 | + @echo "Starting PostgreSQL for unit tests..." |
| 51 | + @docker compose up -d postgres 2>&1 | grep -v "Pulling\|Pulled\|Creating\|Created\|Starting\|Started" || true |
| 52 | + @echo "Waiting for PostgreSQL to be ready..." |
| 53 | + @sleep 3 |
| 54 | + @echo "" |
| 55 | + @echo "Running unit tests (verbose)..." |
| 56 | + @go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/... 2>&1 | grep -v "ld: warning:" | grep -v "^ld:" |
| 57 | + @echo "" |
| 58 | + @go tool cover -html=coverage.out -o coverage.html |
| 59 | + @echo "✅ Coverage report: coverage.html" |
| 60 | + @docker compose down postgres >/dev/null 2>&1 |
40 | 61 |
|
41 | 62 | test: ## Run unit tests (use 'make test-all' to run all tests) |
42 | 63 | @echo "⚠️ Running unit tests only. Use 'make test-all' to run both unit and integration tests." |
|
0 commit comments