| Index: sql/connection_unittest.cc
|
| diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc
|
| index 1afd2dded3366baffe2dc6f831225a8b5395020f..5d894877e9c6b832b60a23508294958d420f6da7 100644
|
| --- a/sql/connection_unittest.cc
|
| +++ b/sql/connection_unittest.cc
|
| @@ -2,16 +2,20 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/bind.h"
|
| #include "base/file_util.h"
|
| #include "base/files/scoped_temp_dir.h"
|
| #include "base/logging.h"
|
| #include "sql/connection.h"
|
| #include "sql/meta_table.h"
|
| #include "sql/statement.h"
|
| +#include "sql/test/error_callback_support.h"
|
| #include "sql/test/scoped_error_ignorer.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "third_party/sqlite/sqlite3.h"
|
|
|
| +namespace {
|
| +
|
| class SQLConnectionTest : public testing::Test {
|
| public:
|
| SQLConnectionTest() {}
|
| @@ -150,6 +154,21 @@ TEST_F(SQLConnectionTest, ScopedIgnoreError) {
|
| ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
|
| }
|
|
|
| +TEST_F(SQLConnectionTest, ErrorCallback) {
|
| + const char* kCreateSql = "CREATE TABLE foo (id INTEGER UNIQUE)";
|
| + ASSERT_TRUE(db().Execute(kCreateSql));
|
| + ASSERT_TRUE(db().Execute("INSERT INTO foo (id) VALUES (12)"));
|
| +
|
| + int error = SQLITE_OK;
|
| + sql::ScopedErrorCallback sec(
|
| + &db(), base::Bind(&sql::CaptureErrorCallback, &error));
|
| +
|
| + // Inserting something other than a number into the primary key
|
| + // should result in SQLITE_MISMATCH.
|
| + EXPECT_FALSE(db().Execute("INSERT INTO foo (id) VALUES (12)"));
|
| + EXPECT_EQ(SQLITE_CONSTRAINT, error);
|
| +}
|
| +
|
| // Test that sql::Connection::Raze() results in a database without the
|
| // tables from the original database.
|
| TEST_F(SQLConnectionTest, Raze) {
|
| @@ -426,3 +445,5 @@ TEST_F(SQLConnectionTest, Delete) {
|
| EXPECT_FALSE(file_util::PathExists(db_path()));
|
| EXPECT_FALSE(file_util::PathExists(journal));
|
| }
|
| +
|
| +} // namespace
|
|
|