Fix failure tests

This commit is contained in:
myasuka 2021-08-20 17:52:14 +08:00
parent d215d73d8d
commit d479f0bb20
2 changed files with 11 additions and 4 deletions

4
cache/cache_test.cc vendored
View File

@ -631,7 +631,7 @@ TEST_P(LRUCacheTest, SetStrictCapacityLimit) {
cache->SetStrictCapacityLimit(true);
Cache::Handle* handle;
s = cache->Insert(extra_key, extra_value, 1, &deleter, &handle);
ASSERT_TRUE(s.IsIncomplete());
ASSERT_TRUE(s.IsOkNotInsertToCache());
ASSERT_EQ(nullptr, handle);
ASSERT_EQ(10, cache->GetUsage());
@ -648,7 +648,7 @@ TEST_P(LRUCacheTest, SetStrictCapacityLimit) {
ASSERT_NE(nullptr, handles[i]);
}
s = cache2->Insert(extra_key, extra_value, 1, &deleter, &handle);
ASSERT_TRUE(s.IsIncomplete());
ASSERT_TRUE(s.IsOkNotInsertToCache());
ASSERT_EQ(nullptr, handle);
// test insert without handle
s = cache2->Insert(extra_key, extra_value, 1, &deleter);

View File

@ -114,7 +114,7 @@ class Status {
kOverwritten = 12,
kTxnNotPrepared = 13,
kIOFenced = 14,
kFailInsertCache = 15,
kNotInsertCache = 15,
kMaxSubCode
};
@ -163,7 +163,7 @@ class Status {
// changing public APIs.
static Status OKNotInsertToCache(const Slice& msg,
const Slice& msg2 = Slice()) {
return Status(kOk, kFailInsertCache, msg, msg2);
return Status(kOk, kNotInsertCache, msg, msg2);
}
// Return error status of an appropriate type.
@ -308,6 +308,13 @@ class Status {
return code() == kOk && subcode() == kOverwritten;
}
// Returns true iff the status indicates success *without*
// inserting to cache
bool IsOkNotInsertToCache() const {
MarkChecked();
return code() == kOk && subcode() == kNotInsertCache;
}
// Returns true iff the status indicates a NotFound error.
bool IsNotFound() const {
MarkChecked();