test: add justfile commands for running integration tests with podman
Build / build (push) Successful in 43s
Build / build (push) Successful in 43s
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
test-db:
|
||||
image: postgres:15-alpine
|
||||
environment:
|
||||
POSTGRES_USER: testuser
|
||||
POSTGRES_PASSWORD: testpass
|
||||
POSTGRES_DB: music_server_test
|
||||
ports:
|
||||
- "5433:5432"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U testuser -d music_server_test"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
volumes:
|
||||
- test-db-data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
test-db-data:
|
||||
@@ -99,6 +99,25 @@ podman-run:
|
||||
podman-down:
|
||||
@podman-compose down
|
||||
|
||||
# Run integration tests with podman
|
||||
# Starts a test PostgreSQL container, runs tests, then cleans up
|
||||
test-integration:
|
||||
@echo "Starting test database container..."
|
||||
@podman-compose -f compose.test.yaml up -d
|
||||
@sleep 10
|
||||
@echo "Running integration tests..."
|
||||
@. .env.test && go test -v -timeout 30m ./...
|
||||
|
||||
# Alternative: Run integration tests using testcontainers with podman provider
|
||||
test-integration-tc:
|
||||
@echo "Running integration tests with testcontainers (podman provider)..."
|
||||
@TESTCONTAINERS_PROVIDER=podman go test -v -timeout 30m .
|
||||
|
||||
# Stop and remove test database container
|
||||
test-integration-down:
|
||||
@echo "Stopping test database container..."
|
||||
@podman-compose -f compose.test.yaml down -v
|
||||
|
||||
# Create DB container
|
||||
docker-run:
|
||||
@if docker compose up --build 2>/dev/null; then \
|
||||
|
||||
Reference in New Issue
Block a user