mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 07:48:57 +00:00
Persist schema migrations
This commit is contained in:
@@ -78,3 +78,29 @@ def test_error_on_future_version(tmp_path: Path):
|
||||
enc_mgr.save_json_data(future)
|
||||
with pytest.raises(ValueError):
|
||||
vault.load_index()
|
||||
|
||||
|
||||
def test_schema_migration_persisted_once(tmp_path: Path):
|
||||
enc_mgr, vault = setup(tmp_path)
|
||||
legacy = {
|
||||
"schema_version": 3,
|
||||
"entries": {
|
||||
"0": {
|
||||
"label": "a",
|
||||
"length": 8,
|
||||
"type": "password",
|
||||
"notes": "",
|
||||
"custom_fields": [],
|
||||
"origin": "",
|
||||
}
|
||||
},
|
||||
}
|
||||
enc_mgr.save_json_data(legacy)
|
||||
data, migrated = vault.load_index(return_migration_flag=True)
|
||||
assert migrated is True
|
||||
assert data["schema_version"] == LATEST_VERSION
|
||||
assert data["entries"]["0"]["tags"] == []
|
||||
|
||||
data_again, migrated_again = vault.load_index(return_migration_flag=True)
|
||||
assert migrated_again is False
|
||||
assert data_again == data
|
||||
|
Reference in New Issue
Block a user