Skip to content

Commit

Permalink
Merge pull request #115 from xsnippet/gabbit-tests-db-fixes
Browse files Browse the repository at this point in the history
Make Gabbit tests run DB migrations
  • Loading branch information
malor committed Jan 26, 2021
2 parents 3add960 + 5deb6ae commit f48f4da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:

- name: Set ROCKET_DATABASE_URL
run: |
echo "ROCKET_DATABASE_URL=postgres://postgres:postgres@localhost/postgres" >> $GITHUB_ENV
echo "ROCKET_DATABASE_URL=postgresql://postgres:postgres@localhost/postgres" >> $GITHUB_ENV
- name: Install Alembic and psycopg2
run: |
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
uses: ./.github/actions/setup-postgres

- run: |
echo "ROCKET_DATABASE_URL=postgres://postgres:postgres@localhost/postgres" >> $GITHUB_ENV
echo "ROCKET_DATABASE_URL=postgresql://postgres:postgres@localhost/postgres" >> $GITHUB_ENV
- run: cargo build
- run: python -m venv testvenv
Expand Down
2 changes: 2 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
alembic >= 1.5.2
gabbi >= 2.1.0
psycopg2-binary >= 2.8.6
pytest >= 6.2.1
4 changes: 4 additions & 0 deletions tests/test_gabbits.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import alembic.config
import json
import os
import random
Expand Down Expand Up @@ -48,6 +49,9 @@ def start_fixture(self):
environ = os.environ.copy()
environ.update(self.environ)

# run database migrations (requires ROCKET_DATABASE_URL to be set)
alembic.config.main(['upgrade', 'head'])

# capture stdout/stderr of xsnippet-api process to a temporary file.
# Alternatively, we could either connect the child process to our
# file descriptors (in which case, log messages from both processes
Expand Down

0 comments on commit f48f4da

Please sign in to comment.