@@ -43,7 +43,6 @@ class UpdateTestBase : public ::testing::Test {
4343 void SetUp () override {
4444 InitializeFileIO ();
4545 RegisterTableFromResource (" TableMetadataV2Valid.json" );
46- RegisterMinimalTableFromResource (" TableMetadataV2ValidMinimal.json" );
4746 }
4847
4948 // / \brief Initialize file IO and create necessary directories.
@@ -57,7 +56,7 @@ class UpdateTestBase : public ::testing::Test {
5756 static_cast <arrow::ArrowFileSystemFileIO&>(*file_io_).fs ());
5857 ASSERT_TRUE (arrow_fs != nullptr );
5958 ASSERT_TRUE (arrow_fs->CreateDir (table_location_ + " /metadata" ).ok ());
60- ASSERT_TRUE (arrow_fs->CreateDir (minimal_table_location_ + " /metadata" ).ok ());
59+ ASSERT_TRUE (arrow_fs->CreateDir (table_location_ + " /metadata" ).ok ());
6160 }
6261
6362 // / \brief Register a table from a metadata resource file.
@@ -80,34 +79,58 @@ class UpdateTestBase : public ::testing::Test {
8079 catalog_->RegisterTable (table_ident_, metadata_location));
8180 }
8281
82+ const TableIdentifier table_ident_{.name = " test_table" };
83+ const std::string table_location_{" /warehouse/test_table" };
84+ std::shared_ptr<FileIO> file_io_;
85+ std::shared_ptr<InMemoryCatalog> catalog_;
86+ std::shared_ptr<Table> table_;
87+ };
88+
89+ // Base test fixture for table update operations on minimal table metadata.
90+ class MinimalUpdateTestBase : public ::testing::Test {
91+ protected:
92+ void SetUp () override {
93+ InitializeFileIO ();
94+ RegisterMinimalTableFromResource (" TableMetadataV2ValidMinimal.json" );
95+ }
96+
97+ // / \brief Initialize file IO and create necessary directories.
98+ void InitializeFileIO () {
99+ file_io_ = arrow::ArrowFileSystemFileIO::MakeMockFileIO ();
100+ catalog_ =
101+ InMemoryCatalog::Make (" test_catalog" , file_io_, " /warehouse/" , /* properties=*/ {});
102+
103+ // Arrow MockFS cannot automatically create directories.
104+ auto arrow_fs = std::dynamic_pointer_cast<::arrow::fs::internal::MockFileSystem>(
105+ static_cast <arrow::ArrowFileSystemFileIO&>(*file_io_).fs ());
106+ ASSERT_TRUE (arrow_fs != nullptr );
107+ ASSERT_TRUE (arrow_fs->CreateDir (table_location_ + " /metadata" ).ok ());
108+ }
109+
83110 // / \brief Register a minimal table from a metadata resource file.
84111 // /
85112 // / \param resource_name The name of the metadata resource file
86113 void RegisterMinimalTableFromResource (const std::string& resource_name) {
87114 // Drop existing table if it exists
88- std::ignore = catalog_->DropTable (minimal_table_ident_ , /* purge=*/ false );
115+ std::ignore = catalog_->DropTable (table_ident_ , /* purge=*/ false );
89116
90117 // Write table metadata to the table location.
91- auto metadata_location =
92- std::format (" {}/metadata/00001-{}.metadata.json" , minimal_table_location_,
93- Uuid::GenerateV7 ().ToString ());
118+ auto metadata_location = std::format (" {}/metadata/00001-{}.metadata.json" ,
119+ table_location_, Uuid::GenerateV7 ().ToString ());
94120 ICEBERG_UNWRAP_OR_FAIL (auto metadata, ReadTableMetadataFromResource (resource_name));
95- metadata->location = minimal_table_location_ ;
121+ metadata->location = table_location_ ;
96122 ASSERT_THAT (TableMetadataUtil::Write (*file_io_, metadata_location, *metadata),
97123 IsOk ());
98124
99125 // Register the table in the catalog.
100- ICEBERG_UNWRAP_OR_FAIL (
101- minimal_table_, catalog_->RegisterTable (minimal_table_ident_ , metadata_location));
126+ ICEBERG_UNWRAP_OR_FAIL (minimal_table_,
127+ catalog_->RegisterTable (table_ident_ , metadata_location));
102128 }
103129
104- const TableIdentifier table_ident_{.name = " test_table" };
105- const std::string table_location_{" /warehouse/test_table" };
106- const TableIdentifier minimal_table_ident_{.name = " minimal_table" };
107- const std::string minimal_table_location_{" /warehouse/minimal_table" };
130+ const TableIdentifier table_ident_{.name = " minimal_table" };
131+ const std::string table_location_{" /warehouse/minimal_table" };
108132 std::shared_ptr<FileIO> file_io_;
109133 std::shared_ptr<InMemoryCatalog> catalog_;
110- std::shared_ptr<Table> table_;
111134 std::shared_ptr<Table> minimal_table_;
112135};
113136
0 commit comments