OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" |
7 #include "sql/connection.h" | 7 #include "sql/connection.h" |
8 #include "sql/statement.h" | 8 #include "sql/statement.h" |
9 #include "sql/meta_table.h" | 9 #include "sql/meta_table.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 EXPECT_FALSE(db().DoesTableExist("FOO")); | 103 EXPECT_FALSE(db().DoesTableExist("FOO")); |
104 | 104 |
105 // Test DoesColumnExist. | 105 // Test DoesColumnExist. |
106 EXPECT_FALSE(db().DoesColumnExist("foo", "bar")); | 106 EXPECT_FALSE(db().DoesColumnExist("foo", "bar")); |
107 EXPECT_TRUE(db().DoesColumnExist("foo", "a")); | 107 EXPECT_TRUE(db().DoesColumnExist("foo", "a")); |
108 | 108 |
109 // Testing for a column on a nonexistent table. | 109 // Testing for a column on a nonexistent table. |
110 EXPECT_FALSE(db().DoesColumnExist("bar", "b")); | 110 EXPECT_FALSE(db().DoesColumnExist("bar", "b")); |
111 } | 111 } |
112 | 112 |
| 113 TEST_F(SQLConnectionTest, GetColumnType) { |
| 114 ASSERT_TRUE(db().Execute("CREATE TABLE foo (a bigint, b varchar)")); |
| 115 |
| 116 EXPECT_EQ(db().GetColumnType(0), COLUMN_TYPE_INTEGER); |
| 117 EXPECT_EQ(db().GetColumnType(1), COLUMN_TYPE_TEXT); |
| 118 } |
| 119 |
113 TEST_F(SQLConnectionTest, GetLastInsertRowId) { | 120 TEST_F(SQLConnectionTest, GetLastInsertRowId) { |
114 ASSERT_TRUE(db().Execute("CREATE TABLE foo (id INTEGER PRIMARY KEY, value)")); | 121 ASSERT_TRUE(db().Execute("CREATE TABLE foo (id INTEGER PRIMARY KEY, value)")); |
115 | 122 |
116 ASSERT_TRUE(db().Execute("INSERT INTO foo (value) VALUES (12)")); | 123 ASSERT_TRUE(db().Execute("INSERT INTO foo (value) VALUES (12)")); |
117 | 124 |
118 // Last insert row ID should be valid. | 125 // Last insert row ID should be valid. |
119 int64 row = db().GetLastInsertRowId(); | 126 int64 row = db().GetLastInsertRowId(); |
120 EXPECT_LT(0, row); | 127 EXPECT_LT(0, row); |
121 | 128 |
122 // It should be the primary key of the row we just inserted. | 129 // It should be the primary key of the row we just inserted. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // Otherwise, sqlite3 doesn't find the correct directory to store | 295 // Otherwise, sqlite3 doesn't find the correct directory to store |
289 // temporary files and will report the error 'unable to open | 296 // temporary files and will report the error 'unable to open |
290 // database file'. | 297 // database file'. |
291 ASSERT_TRUE(meta_table.Init(&db(), 4, 4)); | 298 ASSERT_TRUE(meta_table.Init(&db(), 4, 4)); |
292 } | 299 } |
293 #endif | 300 #endif |
294 | 301 |
295 // TODO(shess): Spin up a background thread to hold other_db, to more | 302 // TODO(shess): Spin up a background thread to hold other_db, to more |
296 // closely match real life. That would also allow testing | 303 // closely match real life. That would also allow testing |
297 // RazeWithTimeout(). | 304 // RazeWithTimeout(). |
OLD | NEW |