Skip to content

Commit

Permalink
waiting for postgres service to start before running test scripts and…
Browse files Browse the repository at this point in the history
… moved env variables
  • Loading branch information
AronBuzogany committed Feb 23, 2024
1 parent 88757ae commit 4b443f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 0 additions & 6 deletions backend/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,5 @@ RUN apt-get update
RUN apt-get install -y --no-install-recommends python3-pip
RUN pip3 install --no-cache-dir -r requirements.txt -r dev-requirements.txt

# Set environment variables
ENV POSTGRES_USER=test_user
ENV POSTGRES_PASSWORD=test_password
ENV POSTGRES_DB=test_database
ENV POSTGRES_HOST=postgres

# Command to run the tests
CMD ["pytest"]
14 changes: 12 additions & 2 deletions backend/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@ services:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_database
healthcheck:
test: ["CMD-SHELL", "pg_isready -U test_user -d test_database"]
interval: 5s
timeout: 3s
retries: 3
start_period: 5s

test-runner:
build:
context: .
dockerfile: Dockerfile.test
depends_on:
- postgres
postgres:
condition: service_healthy
environment:
POSTGRES_HOST: postgres # Use the service name defined in Docker Compose
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_database
volumes:
- .:/app
command: ["pytest"]
command: ["pytest"]

0 comments on commit 4b443f7

Please sign in to comment.