File tree 3 files changed +35
-3
lines changed
3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ RUN apt-get update && apt-get install -y \
10
10
libssl-dev libffi-dev \
11
11
--no-install-recommends
12
12
13
+ RUN apt-get update && apt-get install -y postgresql-client
14
+
13
15
# Create directory for app
14
16
RUN mkdir /app
15
17
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ services:
14
14
15
15
testenv :
16
16
build : .
17
- command : tail -f /dev/null
17
+ command : sh test.sh
18
18
environment :
19
- - SQLALCHEMY_TEST_DATABASE_URI=postgresql+psycopg2 ://postgres:postgres@localhost :5432/task_list_api_test
20
- - NODE_ENV =test
19
+ - SQLALCHEMY_TEST_DATABASE_URI=postgresql://postgres:postgres@postgres :5432/task_list_api_test
20
+ - FLASK_ENV =test
21
21
depends_on :
22
22
postgres :
23
23
condition : service_healthy
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # must match the name of the service for the database in
4
+ # the docker-compose.yml file
5
+ DATABASE_SERVICE=postgres
6
+ COUNTER=0
7
+ EXIT_CODE=1
8
+ SECONDS_BEFORE_TIMEOUT=59
9
+
10
+ # check to see if script is running in docker
11
+ if [ -f /.dockerenv ]; then
12
+
13
+ # spin until database is ready
14
+ while [ $EXIT_CODE -ne 0 ]
15
+ do
16
+ pg_isready -h $DATABASE_SERVICE
17
+ EXIT_CODE=$?
18
+ COUNTER=` expr $COUNTER + 1`
19
+
20
+ sleep 1
21
+
22
+ # Check for time out
23
+ if [ $COUNTER -ge $SECONDS_BEFORE_TIMEOUT ]; then
24
+ echo " Timed Out - Database not Found"
25
+ exit 1
26
+ fi
27
+
28
+ done
29
+ fi
30
+
1
31
pytest
You can’t perform that action at this time.
0 commit comments