Skip to content

Commit 4aa7920

Browse files
committed
test(storage_manager): address CodeRabbit review comments
Update ReadNonOpenedFileAutoOpens and WriteNonOpenedFileAutoOpens to: - Capture open-file count before operation - Assert file was created on disk - Assert open-file count increased by 1
1 parent ef33432 commit 4aa7920

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/storage_manager_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,17 @@ TEST_F(StorageManagerTests, ReadNonOpenedFileAutoOpens) {
249249
const std::string filename = "non_opened_read.db";
250250
cleanup_file("./test_data", filename);
251251

252+
// Capture open-file count before operation
253+
auto before = sm_->get_stats().files_opened.load();
254+
ASSERT_FALSE(sm_->file_exists(filename));
255+
252256
// StorageManager auto-opens files, so read should succeed
253257
char buf[StorageManager::PAGE_SIZE];
254258
EXPECT_TRUE(sm_->read_page(filename, 0, buf));
259+
260+
// Verify file was created and open-file count increased
261+
EXPECT_TRUE(sm_->file_exists(filename));
262+
EXPECT_EQ(sm_->get_stats().files_opened.load(), before + 1);
255263
}
256264

257265
/**
@@ -261,10 +269,18 @@ TEST_F(StorageManagerTests, WriteNonOpenedFileAutoOpens) {
261269
const std::string filename = "non_opened_write.db";
262270
cleanup_file("./test_data", filename);
263271

272+
// Capture open-file count before operation
273+
auto before = sm_->get_stats().files_opened.load();
274+
ASSERT_FALSE(sm_->file_exists(filename));
275+
264276
char buf[StorageManager::PAGE_SIZE];
265277
std::memset(buf, 0xAB, StorageManager::PAGE_SIZE);
266278
// StorageManager auto-opens files, so write should succeed
267279
EXPECT_TRUE(sm_->write_page(filename, 0, buf));
280+
281+
// Verify file was created and open-file count increased
282+
EXPECT_TRUE(sm_->file_exists(filename));
283+
EXPECT_EQ(sm_->get_stats().files_opened.load(), before + 1);
268284
}
269285

270286
/**

0 commit comments

Comments
 (0)