From 08f539abd91aaa5d72b744a9151a21ad9d02ec08 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 23 May 2026 20:02:25 +0200 Subject: [PATCH] test: add justfile commands for running integration tests with podman --- compose.test.yaml | 21 +++++++++++++++++++++ justfile | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 compose.test.yaml diff --git a/compose.test.yaml b/compose.test.yaml new file mode 100644 index 0000000..3850315 --- /dev/null +++ b/compose.test.yaml @@ -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: diff --git a/justfile b/justfile index 21e5098..53f5717 100644 --- a/justfile +++ b/justfile @@ -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 \