Skip to content

Commit

Permalink
chore: increase the coverage in BasicKV
Browse files Browse the repository at this point in the history
  • Loading branch information
SYaoJun committed Aug 14, 2024
1 parent 495265f commit 1e572b3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/BasicKVTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,30 @@ TEST_F(BasicKVTest, BasicKVInsertAndLookup) {
});
}

TEST_F(BasicKVTest, BasicKVInsertDuplicatedKey) {
// create leanstore btree for table records
storage::btree::BasicKV* btree;
const auto* btreeName = "testTree1";

std::string key("key_btree_LL_xxxxxxxxxxxx_");
std::string val("VAL_BTREE_LL_YYYYYYYYYYYY_");

mStore->ExecSync(0, [&]() {
auto res = mStore->CreateBasicKV(btreeName);
EXPECT_TRUE(res);
EXPECT_NE(res.value(), nullptr);

btree = res.value();
cr::Worker::My().StartTx();
EXPECT_EQ(btree->Insert(Slice((const uint8_t*)key.data(), key.size()),
Slice((const uint8_t*)val.data(), val.size())),
OpCode::kOK);
EXPECT_EQ(btree->Insert(Slice((const uint8_t*)key.data(), key.size()),
Slice((const uint8_t*)val.data(), val.size())),
OpCode::kDuplicated);
cr::Worker::My().CommitTx();
});
}


} // namespace leanstore::test

0 comments on commit 1e572b3

Please sign in to comment.