Load the test schema once and truncate data between files.
Deploy Development / deploy (push) Successful in 56s
Test Suite / pytest-backend (push) Successful in 2m43s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 15s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-07 15:07:33 +02:00
1 parent 3c0213ae74
commit 79e4fd0d4b
8 files changed
+78 -25

No files matched your search

+31
View File
@@ -89,6 +89,7 @@ def _require_test_database() -> None:
def reset_postgres_schema() -> None:
import psycopg
from db_init import mark_schema_dirty
from sql_compat import postgres_connect_kwargs
kwargs = postgres_connect_kwargs()
@@ -103,6 +104,36 @@ def reset_postgres_schema() -> None:
conn.execute("GRANT ALL ON SCHEMA public TO CURRENT_USER")
finally:
conn.close()
mark_schema_dirty()
def reset_postgres_data() -> None:
"""Clear rows on kansho_test without reloading schema.sql."""
import psycopg
from sql_compat import postgres_connect_kwargs
kwargs = postgres_connect_kwargs()
if "conninfo" in kwargs:
conn = psycopg.connect(kwargs["conninfo"], autocommit=True)
else:
conn = psycopg.connect(autocommit=True, **kwargs)
try:
rows = conn.execute(
"""
SELECT tablename FROM pg_tables
WHERE schemaname = 'public' AND tablename <> 'schema_migrations'
"""
).fetchall()
names = [row[0] for row in rows]
if names:
joined = ", ".join('"' + name.replace('"', '""') + '"' for name in names)
conn.execute(f"TRUNCATE TABLE {joined} RESTART IDENTITY CASCADE")
finally:
conn.close()
from db import refresh_runtime_seed
refresh_runtime_seed()
def configure_test_engine() -> None: