Merge "Test that you can undo & re-apply all migrations"

This commit is contained in:
Jenkins 2013-01-17 06:19:03 +00:00 committed by Gerrit Code Review
commit 8748cfa3a6

View File

@ -81,6 +81,20 @@ class SqlUpgradeTests(test.TestCase):
version = migration.db_version()
self.assertEqual(version, 0, "DB is at version 0")
def test_two_steps_forward_one_step_back(self):
"""You should be able to cleanly undo a re-apply all upgrades.
Upgrades are run in the following order::
0 -> 1 -> 0 -> 1 -> 2 -> 1 -> 2 -> 3 -> 2 -> 3 ...
^---------^ ^---------^ ^---------^
"""
for x in range(1, self.max_version + 1):
self.upgrade(x)
self.downgrade(x - 1)
self.upgrade(x)
def assertTableColumns(self, table_name, expected_cols):
"""Asserts that the table contains the expected set of columns."""
table = self.select_table(table_name)