Skip to content

Empty every table in the test database helper - #1511

Draft
akalongman wants to merge 1 commit into
devfrom
fix/test-empty-db
Draft

akalongman wants to merge 1 commit into
devfrom
fix/test-empty-db

Conversation

@akalongman

Copy link
Copy Markdown
Member

TestHelpers::emptyDb() runs before every database test, but it deleted from only 11 of the schema's 21 tables, in one multi-statement batch. When a statement in the batch failed, for example the delete from message while an edited_message row referenced it, the batch ended without an error and the tables after it kept their rows. A test could then pass or fail on the rows of an earlier run.

The helper now reads the table list from the server and deletes from each table in its own statement, with foreign key checks off for that connection, so a table added to the schema later is covered and a failing statement throws.

The new test stores a message and an edit of it, calls the helper and checks that edited_message, message, chat and user are empty; it fails on the old helper. CLAUDE.md is updated to say that the helper empties every table of the test database.

TestHelpers::emptyDb() deleted from 11 of the 21 tables in one
multi-statement batch. A statement that failed, such as the delete
from message while an edited_message row referenced it, ended the
batch unnoticed and left the remaining tables full, so a later test
ran on the rows of an earlier one.

It now reads the table list from the server and deletes from each
table in its own statement with foreign key checks off, so a failure
throws.
@akalongman
akalongman marked this pull request as draft November 19, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant