55
66#include < gtest/gtest.h>
77
8+ #include < cstdio>
89#include < cstring>
10+ #include < filesystem>
911#include < vector>
1012
1113#include " catalog/catalog.hpp"
@@ -216,8 +218,10 @@ TEST(CatalogCoverageTests, GetTableIndexes) {
216218 oid_t tid = catalog->create_table (" indexed_table" , cols);
217219 ASSERT_NE (tid, 0 );
218220
219- catalog->create_index (" idx1" , tid, {0 }, IndexType::BTree, false );
220- catalog->create_index (" idx2" , tid, {0 }, IndexType::Hash, true );
221+ oid_t idx1_id = catalog->create_index (" idx1" , tid, {0 }, IndexType::BTree, false );
222+ ASSERT_NE (idx1_id, 0 );
223+ oid_t idx2_id = catalog->create_index (" idx2" , tid, {0 }, IndexType::Hash, true );
224+ ASSERT_NE (idx2_id, 0 );
221225
222226 auto indexes = catalog->get_table_indexes (tid);
223227 EXPECT_EQ (indexes.size (), 2 );
@@ -235,18 +239,23 @@ TEST(CatalogCoverageTests, SaveAndLoad) {
235239 std::vector<ColumnInfo> cols = {{" id" , common::ValueType::TYPE_INT64, 0 }};
236240 catalog->create_table (" persisted_table" , cols);
237241
242+ // Use unique temp path to avoid collisions in parallel runs
243+ static int test_counter = 0 ;
244+ std::string temp_filename = " /tmp/test_catalog_" + std::to_string (++test_counter) + " .bin" ;
245+ std::filesystem::path temp_path (temp_filename);
246+
238247 // Save catalog - should succeed
239- ASSERT_TRUE (catalog->save (" /tmp/test_catalog.bin " ));
248+ ASSERT_TRUE (catalog->save (temp_path. string () ));
240249
241250 // Create new catalog and load - should succeed (returns true)
242251 auto loaded_catalog = Catalog::create ();
243- ASSERT_TRUE (loaded_catalog->load (" /tmp/test_catalog.bin " ));
252+ ASSERT_TRUE (loaded_catalog->load (temp_path. string () ));
244253
245254 // Note: Due to stub implementation, loaded catalog won't have the table
246255 // This test verifies the save/load cycle works without crashing
247256
248257 // Cleanup
249- std::remove (" /tmp/test_catalog.bin " );
258+ std::filesystem:: remove (temp_path );
250259}
251260
252261/* *
0 commit comments