test(migrations): stop the pre-split backup test tracking the app version
`_backup_db` names its copy `homelab.db.back-<APP_VERSION>`, so the 3.4.1 bump renamed the backup `init_db` takes from `back-3.3.2` to `back-3.4.1`. The test hardcoded its post-split copies as `back-3.3.1` / `back-3.3.2`, which happened to overwrite that backup while the version was 3.3.2; at 3.4.1 it survives, still carrying the columns this very boot is about to drop, and wins the newest-first scan in `_pre_split_backup`. The fixture was also unlike a real install, where the current version's backup is taken after the columns are already gone — they went in the 3.3.0 boot, not this one. Copy a post-split database over it too, under whatever the version is, and the test stops breaking on every bump. `_pre_split_backup` is unchanged: preferring the newest backup that still holds the columns is right, the drop boot's own backup included. ha-relevant: no
This commit is contained in:
committed by
Pouzor - Rémy Jardient
parent
574b84d843
commit
7aa322da35
@@ -19,6 +19,7 @@ from sqlalchemy.ext.asyncio import create_async_engine
|
||||
|
||||
import app.db.database as database
|
||||
import app.services.inventory_sync as inventory_sync
|
||||
from app.core.config import APP_VERSION
|
||||
|
||||
# `create_all` under v3.2.0. NOT NULL is reproduced exactly where it was.
|
||||
_NODES_320 = (
|
||||
@@ -412,8 +413,10 @@ async def test_the_newest_backup_that_still_has_the_columns_is_the_one_read(db_3
|
||||
shutil.copy2(db_path, pre_split)
|
||||
|
||||
await database.init_db() # drops the columns, and backs up under this version
|
||||
# Post-split backups: newer, and unable to say who drew what.
|
||||
for name in ("back-3.3.1", "back-3.3.2"):
|
||||
# Post-split backups: newer, and unable to say who drew what. On a real
|
||||
# install the current version's own backup is one of them — the columns went
|
||||
# in an earlier boot, not this one — so overwrite the one `init_db` took.
|
||||
for name in ("back-3.3.1", "back-3.3.2", f"back-{APP_VERSION}"):
|
||||
shutil.copy2(db_path, db_path.parent / f"{db_path.name}.{name}")
|
||||
|
||||
assert database._pre_split_backup() == pre_split
|
||||
|
||||
Reference in New Issue
Block a user