mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
* chore: drop deprecated tables and remove unused code * isort imports * migration: check for table existence before drop
29 lines
944 B
Python
29 lines
944 B
Python
from test.fixtures import *
|
|
|
|
import pytest
|
|
from alembic.script import ScriptDirectory
|
|
from mock import patch
|
|
|
|
from data.runmigration import run_alembic_migration
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"db_uri, is_valid",
|
|
[
|
|
("postgresql://devtable:password@quay-postgres/registry_database", True),
|
|
("postgresql://devtable:password%25@quay-postgres/registry_database", False),
|
|
("postgresql://devtable:password%%25@quay-postgres/registry_database", True),
|
|
("postgresql://devtable@db:password@quay-postgres/registry_database", True),
|
|
],
|
|
)
|
|
def test_alembic_db_uri(db_uri, is_valid):
|
|
"""
|
|
Test if the given URI is escaped for string interpolation (Python's configparser).
|
|
"""
|
|
with patch("alembic.script.ScriptDirectory.run_env") as m:
|
|
if is_valid:
|
|
run_alembic_migration(db_uri)
|
|
else:
|
|
with pytest.raises(ValueError):
|
|
run_alembic_migration(db_uri)
|