Skip to content

Commit 06985e3

Browse files
committed
increasing test coverage for MigrationManager, with changing column types
1 parent 2c4ee2a commit 06985e3

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/apps/migrations/auto/test_migration_manager.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from asyncpg.exceptions import UniqueViolationError
55
from piccolo.apps.migrations.auto import MigrationManager
66
from piccolo.apps.migrations.commands.base import BaseMigrationManager
7-
from piccolo.columns import Varchar
7+
from piccolo.columns import Varchar, Text
88
from piccolo.columns.base import OnDelete, OnUpdate
99

1010
from tests.example_app.tables import Manager
@@ -467,6 +467,30 @@ def test_alter_column_add_index(self):
467467
not in Manager.indexes().run_sync()
468468
)
469469

470+
@postgres_only
471+
def test_alter_column_set_type(self):
472+
"""
473+
Test altering a column to change it's type with MigrationManager.
474+
"""
475+
manager = MigrationManager()
476+
477+
manager.alter_column(
478+
table_class_name="Manager",
479+
tablename="manager",
480+
column_name="name",
481+
params={},
482+
old_params={},
483+
column_class=Text,
484+
old_column_class=Varchar,
485+
)
486+
487+
asyncio.run(manager.run())
488+
489+
column_type_str = self.get_postgres_column_type_str(
490+
tablename="manager", column_name="name"
491+
)
492+
self.assertEqual(column_type_str, "TEXT")
493+
470494
@postgres_only
471495
@patch.object(BaseMigrationManager, "get_migration_managers")
472496
def test_drop_table(self, get_migration_managers: MagicMock):

0 commit comments

Comments
 (0)