Skip to content

Commit dc496a9

Browse files
committed
added an extra test for the new migration command
1 parent 5ac8cfd commit dc496a9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/apps/migrations/commands/test_forwards_backwards.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from piccolo.apps.migrations.tables import Migration
77
from piccolo.apps.migrations.commands.backwards import backwards
88
from piccolo.apps.migrations.commands.forwards import forwards
9+
from tests.base import postgres_only
910
from tests.example_app.tables import (
1011
Band,
1112
Concert,
@@ -29,6 +30,7 @@
2930
]
3031

3132

33+
@postgres_only
3234
class TestForwardsBackwards(TestCase):
3335
"""
3436
How to test this? Add migrations for the example app, and just run them

tests/apps/migrations/commands/test_new.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
from piccolo.apps.migrations.commands.new import (
77
_create_new_migration,
88
BaseMigrationManager,
9+
new,
910
)
1011

12+
from tests.base import postgres_only
1113
from tests.example_app.tables import Manager
1214

1315

1416
class TestNewMigrationCommand(TestCase):
1517
def test_create_new_migration(self):
18+
"""
19+
Create a manual migration (i.e. non-auto).
20+
"""
1621
migration_folder = "/tmp/piccolo_migrations/"
1722

1823
if os.path.exists(migration_folder):
@@ -33,3 +38,15 @@ def test_create_new_migration(self):
3338
)
3439

3540
self.assertTrue(len(migration_modules.keys()) == 1)
41+
42+
@postgres_only
43+
def test_new_command(self):
44+
"""
45+
Call the command, when no migration changes are needed.
46+
"""
47+
with self.assertRaises(SystemExit) as manager:
48+
new(app_name="example_app", auto=True)
49+
50+
self.assertEqual(
51+
manager.exception.__str__(), "No changes detected - exiting."
52+
)

0 commit comments

Comments
 (0)