run alembic in run-test.sh
This commit is contained in:
parent
e74362dd9f
commit
2de5161cd2
|
@ -1,12 +1,19 @@
|
||||||
# Run tests
|
# Run tests
|
||||||
|
|
||||||
|
# Delete the test DB if it isn't properly removed
|
||||||
docker rm -f sl-test-db
|
docker rm -f sl-test-db
|
||||||
|
|
||||||
|
# Create a test DB
|
||||||
docker run -d --name sl-test-db -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test -p 15432:5432 postgres:13
|
docker run -d --name sl-test-db -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test -p 15432:5432 postgres:13
|
||||||
|
|
||||||
# the time the DB container starts
|
# the time for the test DB container to start
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
|
# migrate the DB to the latest version
|
||||||
|
CONFIG=tests/test.env poetry run alembic upgrade head
|
||||||
|
|
||||||
|
# run test
|
||||||
poetry run pytest
|
poetry run pytest
|
||||||
|
|
||||||
|
# Delete the test DB
|
||||||
docker rm -f sl-test-db
|
docker rm -f sl-test-db
|
||||||
|
|
|
@ -9,7 +9,6 @@ os.environ["CONFIG"] = os.path.abspath(
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from app.db import Session, engine, connection
|
from app.db import Session, engine, connection
|
||||||
from app.models import Base
|
|
||||||
|
|
||||||
from psycopg2 import errors
|
from psycopg2 import errors
|
||||||
from psycopg2.errorcodes import DEPENDENT_OBJECTS_STILL_EXIST
|
from psycopg2.errorcodes import DEPENDENT_OBJECTS_STILL_EXIST
|
||||||
|
@ -34,8 +33,6 @@ with engine.connect() as conn:
|
||||||
print(">>> pg_trgm can't be dropped, ignore")
|
print(">>> pg_trgm can't be dropped, ignore")
|
||||||
conn.execute("Rollback")
|
conn.execute("Rollback")
|
||||||
|
|
||||||
# Base.metadata.create_all(engine)
|
|
||||||
|
|
||||||
add_sl_domains()
|
add_sl_domains()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue