From f6b133d1eedac401b4fde51ebea94dab9019a4fe Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Wed, 16 Jan 2013 11:16:04 -0600 Subject: [PATCH] Test that you can undo & re-apply all migrations Change-Id: I72e2b979a8692657c225102f2562e1b1fbb3f67d --- tests/test_sql_upgrade.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_sql_upgrade.py b/tests/test_sql_upgrade.py index 090756e0ce..0112473b55 100644 --- a/tests/test_sql_upgrade.py +++ b/tests/test_sql_upgrade.py @@ -63,6 +63,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)