Tag functionality added
This commit is contained in:
@@ -1,22 +1,27 @@
|
||||
import sqlite3
|
||||
|
||||
from backend.app.database import apply_migrations, get_schema_version
|
||||
from backend.app.database import DEFAULT_TAGS, apply_migrations, get_schema_version, seed_default_tags
|
||||
|
||||
|
||||
def test_database_migrations_are_versioned_and_idempotent():
|
||||
connection = sqlite3.connect(':memory:')
|
||||
|
||||
apply_migrations(connection)
|
||||
assert get_schema_version(connection) == 1
|
||||
assert get_schema_version(connection) == 3
|
||||
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
|
||||
assert {
|
||||
'users', 'tokens', 'links', 'plugins', 'user_plugin_config', 'tags', 'link_tags'
|
||||
} <= tables
|
||||
seed_default_tags(connection)
|
||||
seeded_tags = {row[0] for row in connection.execute('SELECT name FROM tags')}
|
||||
assert set(DEFAULT_TAGS) <= seeded_tags
|
||||
|
||||
apply_migrations(connection)
|
||||
assert get_schema_version(connection) == 1
|
||||
assert get_schema_version(connection) == 3
|
||||
|
||||
connection.close()
|
||||
Reference in New Issue
Block a user