mirror of
https://github.com/evroon/bracket.git
synced 2026-09-17 08:29:18 -04:00
Validate table names in test row counter
This commit is contained in:
1 parent
9635911924
commit
ad2af69695
1 file changed
+4
@@ -31,8 +31,12 @@ from bracket.utils.id_types import TeamId
|
||||
from tests.integration_tests.mocks import get_mock_token, get_mock_user
|
||||
from tests.integration_tests.models import AuthContext
|
||||
|
||||
ROW_COUNT_TABLES = {"courts", "matches", "players", "rounds", "stage_items", "stages", "teams"}
|
||||
|
||||
|
||||
async def assert_row_count_and_clear(table_name: str, expected_rows: int) -> None:
|
||||
if table_name not in ROW_COUNT_TABLES:
|
||||
raise ValueError(f"Unsupported table for row count assertion: {table_name}")
|
||||
rows = await database.fetch_val(query=f"SELECT COUNT(*) FROM {table_name}")
|
||||
assert rows == expected_rows
|
||||
await database.execute(query=f"DELETE FROM {table_name}")
|
||||
|
||||
Reference in new issue
Block a user