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

Unified Diff: components/leveldb_proto/proto_database_impl_unittest.cc

Issue 735823004: Make ProtoDatabase properly handle failed Init (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « components/leveldb_proto/leveldb_database.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb_proto/proto_database_impl_unittest.cc
diff --git a/components/leveldb_proto/proto_database_impl_unittest.cc b/components/leveldb_proto/proto_database_impl_unittest.cc
index 095b9d4b2135011813e2c89967d9d87d888e4ece..e1d31440d012f8faa254a7ed9d25fca617db2724 100644
--- a/components/leveldb_proto/proto_database_impl_unittest.cc
+++ b/components/leveldb_proto/proto_database_impl_unittest.cc
@@ -15,6 +15,7 @@
#include "components/leveldb_proto/testing/proto/test.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/leveldatabase/src/include/leveldb/options.h"
using base::MessageLoop;
using base::ScopedTempDir;
@@ -394,4 +395,21 @@ TEST(ProtoDatabaseImplLevelDBTest, TestDBCloseAndReopen) {
TestLevelDBSaveAndLoad(true);
}
+TEST(ProtoDatabaseImplLevelDBTest, TestDBInitFail) {
+ ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+
+ leveldb::Options options;
+ options.create_if_missing = false;
+ scoped_ptr<LevelDB> db(new LevelDB());
+
+ KeyValueVector save_entries;
+ std::vector<std::string> load_entries;
+ KeyVector remove_keys;
+
+ EXPECT_FALSE(db->InitWithOptions(temp_dir.path(), options));
+ EXPECT_FALSE(db->Load(&load_entries));
+ EXPECT_FALSE(db->Save(save_entries, remove_keys));
+}
+
} // namespace leveldb_proto
« no previous file with comments | « components/leveldb_proto/leveldb_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698