OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sql/recovery.h" | 5 #include "sql/recovery.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 ASSERT_TRUE(recovery.get()); | 96 ASSERT_TRUE(recovery.get()); |
97 sql::Recovery::Unrecoverable(std::move(recovery)); | 97 sql::Recovery::Unrecoverable(std::move(recovery)); |
98 | 98 |
99 // TODO(shess): Test that calls to recover.db() start failing. | 99 // TODO(shess): Test that calls to recover.db() start failing. |
100 } | 100 } |
101 EXPECT_FALSE(db().is_open()); | 101 EXPECT_FALSE(db().is_open()); |
102 ASSERT_TRUE(Reopen()); | 102 ASSERT_TRUE(Reopen()); |
103 EXPECT_TRUE(db().is_open()); | 103 EXPECT_TRUE(db().is_open()); |
104 ASSERT_EQ("", GetSchema(&db())); | 104 ASSERT_EQ("", GetSchema(&db())); |
105 | 105 |
106 // Attempting to recover a previously-recovered handle fails early. | |
107 { | |
108 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path()); | |
109 ASSERT_TRUE(recovery.get()); | |
110 recovery.reset(); | |
111 | |
112 recovery = sql::Recovery::Begin(&db(), db_path()); | |
113 ASSERT_FALSE(recovery.get()); | |
Ryan Hamilton
2016/02/02 05:00:06
Presumably, this test failed or crashed with the o
| |
114 } | |
115 ASSERT_TRUE(Reopen()); | |
116 | |
106 // Recreate the database. | 117 // Recreate the database. |
107 ASSERT_TRUE(db().Execute(kCreateSql)); | 118 ASSERT_TRUE(db().Execute(kCreateSql)); |
108 ASSERT_TRUE(db().Execute(kInsertSql)); | 119 ASSERT_TRUE(db().Execute(kInsertSql)); |
109 ASSERT_EQ("CREATE TABLE x (t TEXT)", GetSchema(&db())); | 120 ASSERT_EQ("CREATE TABLE x (t TEXT)", GetSchema(&db())); |
110 | 121 |
111 // Recovered() replaces the original with the "recovered" version. | 122 // Recovered() replaces the original with the "recovered" version. |
112 { | 123 { |
113 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path()); | 124 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path()); |
114 ASSERT_TRUE(recovery.get()); | 125 ASSERT_TRUE(recovery.get()); |
115 | 126 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path()); | 712 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path()); |
702 ASSERT_TRUE(recovery.get()); | 713 ASSERT_TRUE(recovery.get()); |
703 | 714 |
704 // In the current implementation, the PRAGMA successfully runs with no result | 715 // In the current implementation, the PRAGMA successfully runs with no result |
705 // rows. Running with a single result of |0| is also acceptable. | 716 // rows. Running with a single result of |0| is also acceptable. |
706 sql::Statement s(recovery->db()->GetUniqueStatement("PRAGMA mmap_size")); | 717 sql::Statement s(recovery->db()->GetUniqueStatement("PRAGMA mmap_size")); |
707 EXPECT_TRUE(!s.Step() || !s.ColumnInt64(0)); | 718 EXPECT_TRUE(!s.Step() || !s.ColumnInt64(0)); |
708 } | 719 } |
709 | 720 |
710 } // namespace | 721 } // namespace |
OLD | NEW |