diff options
Diffstat (limited to '')
| -rw-r--r-- | tests/test_cli.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py index c98b2fc..f5535d2 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -243,6 +243,20 @@ def test_upgrade_applies_pending_migrations_and_preserves_data( assert "sent_webmentions" in inspect(connection).get_table_names() +@pytest.mark.parametrize("existing_head", ("3e8c87a96b2d", "9a4e0c8211d6")) +def test_upgrade_merges_existing_migration_branches( + database_app: Flask, existing_head: str +) -> None: + """Existing installations on either branch can upgrade to a single head.""" + with database_app.app_context(): + migrate_upgrade(revision=existing_head) + migrate_upgrade() + + assert _database_revision(database_app) == _head_revision(database_app) + tables = set(inspect(db.engine).get_table_names()) + assert {"blocked_sources", "allowed_sources", "source_documents"} <= tables + + def test_upgrade_is_safe_to_run_when_already_current(database_app: Flask) -> None: runner = database_app.test_cli_runner() assert runner.invoke(args=["db", "create-db"]).exit_code == 0 |
