summaryrefslogtreecommitdiffstats
path: root/sync/syncable
diff options
context:
space:
mode:
authormaniscalco@chromium.org <maniscalco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-04 07:08:31 +0000
committermaniscalco@chromium.org <maniscalco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-04 07:08:31 +0000
commit5057c849347f7b826436ab838336f7e7ac7a1568 (patch)
tree0ce15c4ae1771baa86cafb00854f5d67a8a07ff3 /sync/syncable
parentc4640a13a0145bf41cbe87091f230eaf8cd870a9 (diff)
downloadchromium_src-5057c849347f7b826436ab838336f7e7ac7a1568.zip
chromium_src-5057c849347f7b826436ab838336f7e7ac7a1568.tar.gz
chromium_src-5057c849347f7b826436ab838336f7e7ac7a1568.tar.bz2
Rewrite instructions on how to dump sync database for unit test.
directory_backing_store_unittest.cc must be kept up to date with a dump of test data in the latest sync database format. This change updates the instructions for obtaining a dump by adding a dump specific test case that writes to a file on disk so the database can be dumped with the sqlite3 command line tool. BUG=348625 Review URL: https://codereview.chromium.org/185953002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/syncable')
-rw-r--r--sync/syncable/directory_backing_store_unittest.cc48
1 files changed, 35 insertions, 13 deletions
diff --git a/sync/syncable/directory_backing_store_unittest.cc b/sync/syncable/directory_backing_store_unittest.cc
index f53dfb7..417853e 100644
--- a/sync/syncable/directory_backing_store_unittest.cc
+++ b/sync/syncable/directory_backing_store_unittest.cc
@@ -3050,6 +3050,39 @@ TEST_F(DirectoryBackingStoreTest, MigrateVersion85To86) {
}
}
+// The purpose of this test case is to make it easier to get a dump of the
+// database so you can implement a SetUpVersionYDatabase method. Here's what
+// you should do:
+//
+// 1. Say you're going from version X to version Y. Write the migration
+// method MigrateVersionXToY.
+// 2. Update the test below to call SetUpVersionXDatabase and then
+// MigrateVersionXToY. You now have a database at version Y. Let's dump it.
+// 3. Set a breakpoint to stop execution just after the connection is
+// destroyed. Examine temp_dir_ to find the version Y database that was
+// created on disk. E.g. (gdb) p temp_dir_.path().value().c_str()
+// 4. Dump the database using the sqlite3 command line tool:
+// > .output foo_dump.sql
+// > .dump
+// 5. Replace the timestamp columns with META_PROTO_TIMES(x) (or
+// LEGACY_META_PROTO_TIMES(x) if before Version 77). Use this dump to write
+// a SetupVersionYDatabase method.
+TEST_F(DirectoryBackingStoreTest, MigrateToLatestAndDump) {
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ SetUpVersion85Database(&connection); // Update this.
+
+ scoped_ptr<TestDirectoryBackingStore> dbs(
+ new TestDirectoryBackingStore(GetUsername(), &connection));
+ ASSERT_TRUE(dbs->MigrateVersion85To86()); // Update this.
+ ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
+ EXPECT_EQ(86, dbs->GetVersion()); // Update this.
+ ASSERT_FALSE(dbs->needs_column_refresh_);
+ }
+ // Set breakpoint here.
+}
+
TEST_F(DirectoryBackingStoreTest, DetectInvalidPosition) {
sql::Connection connection;
ASSERT_TRUE(connection.OpenInMemory());
@@ -3144,19 +3177,8 @@ TEST_P(MigrationTest, ToCurrentVersion) {
// If you see this error, it may mean that you've increased the
// database version number but you haven't finished adding unit tests
// for the database migration code. You need to need to supply a
- // SetUpVersionXXDatabase function with a dump of the test database
- // at the old schema. Here's one way to do that:
- // 1. Start on a clean tree (with none of your pending schema changes).
- // 2. Set a breakpoint in this function and run the unit test.
- // 3. Allow this test to run to completion (step out of the call),
- // without allowing ~MigrationTest to execute.
- // 4. Examine this->temp_dir_ to determine the location of the
- // test database (it is currently of the version you need).
- // 5. Dump this using the sqlite3 command line tool:
- // > .output foo_dump.sql
- // > .dump
- // 6. Replace the timestamp columns with META_PROTO_TIMES(x) (or
- // LEGACY_META_PROTO_TIMES(x) if before Version 77).
+ // SetUpVersionYDatabase function with a dump of the test database
+ // at the new schema. See the MigrateToLatestAndDump test case.
FAIL() << "Need to supply database dump for version " << GetParam();
}