Skip to content

Commit

Permalink
Test showing alphabetical order does not matter, refs #6
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Mar 13, 2024
1 parent 9830fcd commit 5282220
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_sqlite_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ def m001(db):
@migrations()
def m002(db):
db["cats"].create({"name": str})
db.query("insert into dogs (name) values ('Pancakes')")

return migrations


@pytest.fixture
def migrations_not_ordered_alphabetically():
# Names order alphabetically in the wrong direction but this
# should still be applied correctly
migrations = Migrations("test")

@migrations()
def m002(db):
db["dogs"].insert({"name": "Cleo"})

@migrations()
def m001(db):
db["cats"].create({"name": str})
db.query("insert into dogs (name) values ('Pancakes')")

return migrations

Expand Down Expand Up @@ -54,6 +73,14 @@ def test_two_migration_sets(migrations, migrations2):
assert set(db.table_names()) == {"_sqlite_migrations", "dogs", "cats", "dogs2"}


def test_order_does_not_matter(migrations, migrations_not_ordered_alphabetically):
db1 = sqlite_utils.Database(memory=True)
db2 = db = sqlite_utils.Database(memory=True)
migrations.apply(db1)
migrations_not_ordered_alphabetically.apply(db2)
assert db1.schema == db2.schema


def test_upgrades_sqlite_migrations_from_one_to_two_primary_keys(migrations):
db = sqlite_utils.Database(memory=True)
db["_sqlite_migrations"].create(
Expand Down

0 comments on commit 5282220

Please sign in to comment.