test: clean worker test DB before each test to prevent flakiness

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-10 17:02:38 +02:00
parent 49b69c592d
commit fc1229b885
+5
View File
@@ -8,6 +8,11 @@ import pytest
def conn(): def conn():
dsn = os.environ["DATABASE_URL"] dsn = os.environ["DATABASE_URL"]
connection = psycopg.connect(dsn) connection = psycopg.connect(dsn)
# Clean up any pre-existing rows before the test runs (Job cascades from Request).
with connection.cursor() as cur:
cur.execute('DELETE FROM "Job"')
cur.execute('DELETE FROM "Request"')
connection.commit()
yield connection yield connection
# Clean up rows created during the test (Job cascades from Request). # Clean up rows created during the test (Job cascades from Request).
with connection.cursor() as cur: with connection.cursor() as cur: