Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions tests/catalog_coverage_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

#include <gtest/gtest.h>

#include <cstdio>
#include <cstring>
#include <filesystem>
#include <vector>

#include "catalog/catalog.hpp"
Expand Down Expand Up @@ -216,8 +218,10 @@ TEST(CatalogCoverageTests, GetTableIndexes) {
oid_t tid = catalog->create_table("indexed_table", cols);
ASSERT_NE(tid, 0);

catalog->create_index("idx1", tid, {0}, IndexType::BTree, false);
catalog->create_index("idx2", tid, {0}, IndexType::Hash, true);
oid_t idx1_id = catalog->create_index("idx1", tid, {0}, IndexType::BTree, false);
ASSERT_NE(idx1_id, 0);
oid_t idx2_id = catalog->create_index("idx2", tid, {0}, IndexType::Hash, true);
ASSERT_NE(idx2_id, 0);

auto indexes = catalog->get_table_indexes(tid);
EXPECT_EQ(indexes.size(), 2);
Expand All @@ -235,18 +239,23 @@ TEST(CatalogCoverageTests, SaveAndLoad) {
std::vector<ColumnInfo> cols = {{"id", common::ValueType::TYPE_INT64, 0}};
catalog->create_table("persisted_table", cols);

// Use unique temp path to avoid collisions in parallel runs
static int test_counter = 0;
std::string temp_filename = "/tmp/test_catalog_" + std::to_string(++test_counter) + ".bin";
std::filesystem::path temp_path(temp_filename);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

// Save catalog - should succeed
ASSERT_TRUE(catalog->save("/tmp/test_catalog.bin"));
ASSERT_TRUE(catalog->save(temp_path.string()));

// Create new catalog and load - should succeed (returns true)
auto loaded_catalog = Catalog::create();
ASSERT_TRUE(loaded_catalog->load("/tmp/test_catalog.bin"));
ASSERT_TRUE(loaded_catalog->load(temp_path.string()));

// Note: Due to stub implementation, loaded catalog won't have the table
// This test verifies the save/load cycle works without crashing

// Cleanup
std::remove("/tmp/test_catalog.bin");
std::filesystem::remove(temp_path);
}

/**
Expand Down
Loading