mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
Add test postgres docker compose
This commit is contained in:
21
server/docker-compose.test.yaml
Normal file
21
server/docker-compose.test.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: lemma_test
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
20
server/run_integration_tests.sh
Executable file
20
server/run_integration_tests.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
COMPOSE_FILE=docker-compose.test.yaml
|
||||
|
||||
if ! docker compose -f $COMPOSE_FILE ps postgres | grep -q "running"; then
|
||||
docker compose -f $COMPOSE_FILE up -d
|
||||
until docker compose -f $COMPOSE_FILE exec postgres pg_isready -U postgres; do
|
||||
sleep 1
|
||||
done
|
||||
echo "PostgreSQL is ready!"
|
||||
fi
|
||||
|
||||
export LEMMA_TEST_POSTGRES_URL="postgres://postgres:postgres@localhost:5432/lemma_test?sslmode=disable"
|
||||
|
||||
echo "Running integration tests..."
|
||||
go test -v -tags=integration ./...
|
||||
|
||||
docker compose -f $COMPOSE_FILE down
|
||||
Reference in New Issue
Block a user