diff options
author | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 08:15:39 +0000 |
---|---|---|
committer | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 08:15:39 +0000 |
commit | bb4945f391a07185835963cc7c4d7c6e4d7ae887 (patch) | |
tree | eb2e17300667418fba8fd6a4922bc43499b6e764 /components/webdata/common | |
parent | 12d2bdf9693cd8229bfa594318c417a170e4b83e (diff) | |
download | chromium_src-bb4945f391a07185835963cc7c4d7c6e4d7ae887.zip chromium_src-bb4945f391a07185835963cc7c4d7c6e4d7ae887.tar.gz chromium_src-bb4945f391a07185835963cc7c4d7c6e4d7ae887.tar.bz2 |
Fix version_54.sql golden file.
This patch brings version_54.sql up-to-date with version 54 schema.
Golden files should never be altered, except if they turn out to be not
golden. The fix involves two changes in version_54.sql:
1) Replaces address_line_X and country columns in autofill_profiles
table with columns street_address, dependent_locality, and
sorting_code.
2) Remove column type from autofill_profile_phones table.
These changes were introduced in version 53 schema.
The patch also adds a test that verifies that migrating from
version_53.sql or version_54.sql results in the same schema as migrating
from an empty database. This test will enforce the schema consistency
for the new version_XX.sql files as well.
TEST=WebDatabaseMigrationTest.VersionXxSqlFilesAreGolden
BUG=358300
Review URL: https://codereview.chromium.org/213833011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/webdata/common')
-rw-r--r-- | components/webdata/common/web_database_migration_unittest.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/components/webdata/common/web_database_migration_unittest.cc b/components/webdata/common/web_database_migration_unittest.cc index 0d0c487..10bd12a 100644 --- a/components/webdata/common/web_database_migration_unittest.cc +++ b/components/webdata/common/web_database_migration_unittest.cc @@ -12,6 +12,7 @@ #include "base/stl_util.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "base/values.h" @@ -155,6 +156,14 @@ void CheckNoBackupData(const sql::Connection& connection, EXPECT_FALSE(connection.DoesTableExist("keywords_backup")); } +std::string RemoveQuotes(const std::string& has_quotes) { + // SQLite quotes: http://www.sqlite.org/lang_keywords.html + static const char kQuotes[] = "\"[]`"; + std::string no_quotes; + base::RemoveChars(has_quotes, kQuotes, &no_quotes); + return no_quotes; +} + } // anonymous namespace // The WebDatabaseMigrationTest encapsulates testing of database migrations. @@ -260,6 +269,25 @@ void WebDatabaseMigrationTest::LoadDatabase( ASSERT_TRUE(connection.Execute(contents.data())); } +// Tests that migrating from the golden files version_XX.sql results in the same +// schema as migrating from an empty database. +TEST_F(WebDatabaseMigrationTest, VersionXxSqlFilesAreGolden) { + DoMigration(); + sql::Connection connection; + ASSERT_TRUE(connection.Open(GetDatabasePath())); + const std::string& expected_schema = RemoveQuotes(connection.GetSchema()); + static const int kFirstVersion = 53; + for (int i = kFirstVersion; i < kCurrentTestedVersionNumber; ++i) { + connection.Raze(); + const base::FilePath& file_name = base::FilePath::FromUTF8Unsafe( + "version_" + base::IntToString(i) + ".sql"); + ASSERT_NO_FATAL_FAILURE(LoadDatabase(file_name.value())) + << "Failed to load " << file_name.MaybeAsASCII(); + DoMigration(); + EXPECT_EQ(expected_schema, RemoveQuotes(connection.GetSchema())); + } +} + // Tests that the all migrations from an empty database succeed. TEST_F(WebDatabaseMigrationTest, MigrateEmptyToCurrent) { DoMigration(); |