Skip to content

Commit

Permalink
Correctly track alter-table for rename operation, refs #54
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 18, 2024
1 parent 0864ba4 commit 2d32e90
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_edit_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ async def test_rename_table(db_path, new_name, should_work, expected_message):
csrftoken = (
await ds.client.get("/-/edit-schema/data/creatures", cookies=cookies)
).cookies["ds_csrftoken"]
before_schema = sqlite_utils.Database(db_path)["creatures"].schema
response = await ds.client.post(
"/-/edit-schema/data/creatures",
data={
Expand All @@ -640,6 +641,15 @@ async def test_rename_table(db_path, new_name, should_work, expected_message):
messages = ds.unsign(response.cookies["ds_messages"], "messages")
assert len(messages) == 1
assert messages[0][0] == expected_message
if should_work:
# Should have tracked alter-table against the new table name
event = get_last_event(ds)
if expected_message == "Table name was the same":
assert event is None
else:
assert event.name == "alter-table"
assert event.before_schema == before_schema
assert event.after_schema == sqlite_utils.Database(db_path)[new_name].schema


@pytest.mark.asyncio
Expand Down

0 comments on commit 2d32e90

Please sign in to comment.