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

Unified Diff: net/disk_cache/entry_unittest.cc

Issue 2862943002: SimpleCache: try to recover on CreateEntry on missing cache dir (Closed)
Patch Set: Rebase Created 3 years, 7 months 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 | « no previous file | net/disk_cache/simple/simple_synchronous_entry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/entry_unittest.cc
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index 85dd85a369eede8151c6c53be108176b21e22ed7..55f9cf98f265e219a5a0fc5e6250e370ce2f7013 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -20,6 +20,7 @@
#include "net/base/test_completion_callback.h"
#include "net/disk_cache/blockfile/backend_impl.h"
#include "net/disk_cache/blockfile/entry_impl.h"
+#include "net/disk_cache/cache_util.h"
#include "net/disk_cache/disk_cache_test_base.h"
#include "net/disk_cache/disk_cache_test_util.h"
#include "net/disk_cache/memory/mem_entry_impl.h"
@@ -4300,3 +4301,24 @@ TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptLength) {
disk_cache::simple_util::CorruptStream0LengthFromEntry(key, cache_path_));
EXPECT_NE(net::OK, OpenEntry(key, &entry));
}
+
+TEST_F(DiskCacheEntryTest, SimpleCacheCreateRecoverFromRmdir) {
+ // This test runs as APP_CACHE to make operations more synchronous.
+ // (in particular we want to see if create succeeded or not, so we don't
+ // want an optimistic one).
+ SetCacheType(net::APP_CACHE);
+ SetSimpleCacheMode();
+ InitCache();
+
+ // Pretend someone deleted the cache dir. This shouldn't be too scary in
+ // the test since cache_path_ is set as:
+ // CHECK(temp_dir_.CreateUniqueTempDir());
+ // cache_path_ = temp_dir_.GetPath();
+ disk_cache::DeleteCache(cache_path_,
+ true /* delete the dir, what we really want*/);
+
+ disk_cache::Entry* entry;
+ std::string key("a key");
+ ASSERT_THAT(CreateEntry(key, &entry), IsOk());
+ entry->Close();
+}
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698