22 lines
613 B
Python
22 lines
613 B
Python
import sqlite3
|
|
|
|
from backend.app.database import apply_migrations, get_schema_version
|
|
|
|
|
|
def test_database_migrations_are_versioned_and_idempotent():
|
|
connection = sqlite3.connect(':memory:')
|
|
|
|
apply_migrations(connection)
|
|
assert get_schema_version(connection) == 1
|
|
tables = {
|
|
row[0]
|
|
for row in connection.execute(
|
|
"SELECT name FROM sqlite_master WHERE type = 'table'"
|
|
)
|
|
}
|
|
assert {'users', 'tokens', 'links', 'plugins', 'user_plugin_config'} <= tables
|
|
|
|
apply_migrations(connection)
|
|
assert get_schema_version(connection) == 1
|
|
|
|
connection.close() |