forked from Tribler/tribler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
|
||
from tribler.core.components.database.db.tribler_database import TriblerDatabase | ||
from tribler.core.upgrade.tribler_db.migration_chain import TriblerDatabaseMigrationChain | ||
from tribler.core.utilities.path_util import Path | ||
from tribler.core.utilities.simpledefs import STATEDIR_DB_DIR | ||
|
||
|
||
# pylint: disable=redefined-outer-name | ||
|
||
|
||
@pytest.fixture | ||
def migration_chain(tmpdir): | ||
db_file_name = Path(tmpdir) / STATEDIR_DB_DIR / 'tribler.db' | ||
db_file_name.parent.mkdir() | ||
TriblerDatabase(filename=str(db_file_name)) | ||
return TriblerDatabaseMigrationChain(state_dir=Path(tmpdir), chain=[]) |
13 changes: 13 additions & 0 deletions
13
src/tribler/core/upgrade/tribler_db/scheme_migrations/tests/test_scheme_migration_0.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from tribler.core.upgrade.tribler_db.migration_chain import TriblerDatabaseMigrationChain | ||
from tribler.core.upgrade.tribler_db.scheme_migrations.scheme_migration_0 import scheme_migration_0 | ||
from tribler.core.utilities.pony_utils import db_session | ||
|
||
|
||
@db_session | ||
def test_scheme_migration_0(migration_chain: TriblerDatabaseMigrationChain): | ||
""" Test that the scheme_migration_0 changes the database version to 1. """ | ||
migration_chain.db.version = 0 | ||
migration_chain.migrations = [scheme_migration_0] | ||
|
||
assert migration_chain.execute() | ||
assert migration_chain.db.version == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters