Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2910)

Unified Diff: chrome/browser/webdata/web_database_migration_unittest.cc

Issue 7396024: Adding a sync_guid field to TemplateURL. Adding appropriate database migration changes and tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Lint fix. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/webdata/web_database.cc ('k') | chrome/test/data/web_database/version_38.sql » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_database_migration_unittest.cc
===================================================================
--- chrome/browser/webdata/web_database_migration_unittest.cc (revision 92870)
+++ chrome/browser/webdata/web_database_migration_unittest.cc (working copy)
@@ -186,7 +186,7 @@
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 38;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 39;
void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
std::string contents;
@@ -1464,3 +1464,43 @@
EXPECT_TRUE(connection.DoesColumnExist("keywords", "last_modified"));
}
}
+
+// Tests that the |keywords| |sync_guid| column gets added to the schema for
+// a version 38 database.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion38ToCurrent) {
+ // This schema is taken from a build prior to the addition of the |keywords|
+ // |sync_guid| column.
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_38.sql")));
+
+ // Verify pre-conditions. These are expectations for version 38 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+
+ // Columns existing and not existing before current version.
+ ASSERT_TRUE(connection.DoesColumnExist("keywords", "id"));
+ ASSERT_FALSE(connection.DoesColumnExist("keywords", "sync_guid"));
+ }
+
+ // Load the database via the WebDatabase class and migrate the database to
+ // the current version.
+ {
+ WebDatabase db;
+ ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
+ }
+
+ // Verify post-conditions. These are expectations for current version of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+
+ // |keywords| |sync_guid| column should have been added.
+ EXPECT_TRUE(connection.DoesColumnExist("keywords", "id"));
+ EXPECT_TRUE(connection.DoesColumnExist("keywords", "sync_guid"));
+ }
+}
« no previous file with comments | « chrome/browser/webdata/web_database.cc ('k') | chrome/test/data/web_database/version_38.sql » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698