Skip to content

Commit c0c6ae7

Browse files
author
shuxu.li
committed
feat: Refresh method support for table
1 parent ef6bab3 commit c0c6ae7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/in_memory_catalog_test.cc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class InMemoryCatalogTest : public ::testing::Test {
3838
file_io_ = std::make_shared<iceberg::arrow::ArrowFileSystemFileIO>(
3939
std::make_shared<::arrow::fs::LocalFileSystem>());
4040
std::unordered_map<std::string, std::string> properties = {{"prop1", "val1"}};
41-
catalog_ = std::make_shared<MockInMemoryCatalog>("test_catalog", file_io_,
42-
"/tmp/warehouse/", properties);
41+
catalog_ = std::make_shared<InMemoryCatalog>("test_catalog", file_io_,
42+
"/tmp/warehouse/", properties);
4343
}
4444

4545
void TearDown() override {
@@ -73,7 +73,7 @@ class InMemoryCatalogTest : public ::testing::Test {
7373
}
7474

7575
std::shared_ptr<FileIO> file_io_;
76-
std::shared_ptr<MockInMemoryCatalog> catalog_;
76+
std::shared_ptr<InMemoryCatalog> catalog_;
7777
// Used to store temporary paths created during the test
7878
std::vector<std::string> created_temp_paths_;
7979
};
@@ -116,9 +116,12 @@ TEST_F(InMemoryCatalogTest, RegisterTable) {
116116

117117
TEST_F(InMemoryCatalogTest, RefreshTable) {
118118
TableIdentifier tableIdent{.ns = {}, .name = "t1"};
119-
119+
std::shared_ptr<MockInMemoryCatalog> mock_catalog =
120+
std::make_shared<MockInMemoryCatalog>(
121+
"mock_catalog", file_io_, "/tmp/warehouse/",
122+
std::unordered_map<std::string, std::string>());
120123
auto table_location = GenerateTestTableLocation(tableIdent.name);
121-
auto buildTable = [this, &tableIdent, &table_location](
124+
auto buildTable = [this, &tableIdent, &mock_catalog, &table_location](
122125
int64_t snapshot_id, int64_t version) -> std::unique_ptr<Table> {
123126
std::unique_ptr<TableMetadata> metadata;
124127

@@ -130,19 +133,20 @@ TEST_F(InMemoryCatalogTest, RefreshTable) {
130133
EXPECT_THAT(status, IsOk());
131134

132135
return std::make_unique<Table>(tableIdent, std::move(metadata), metadata_location,
133-
file_io_, std::static_pointer_cast<Catalog>(catalog_));
136+
file_io_,
137+
std::static_pointer_cast<Catalog>(mock_catalog));
134138
};
135139

136140
auto table_v0 = buildTable(3051729675574597004, 0);
137141
auto table_v1 = buildTable(3055729675574597004, 1);
138-
EXPECT_CALL(*catalog_, LoadTable(::testing::_))
142+
EXPECT_CALL(*mock_catalog, LoadTable(::testing::_))
139143
.WillOnce(::testing::Return(
140144
::testing::ByMove(Result<std::unique_ptr<Table>>(std::move(table_v0)))))
141145
.WillOnce(::testing::Return(
142146
::testing::ByMove(Result<std::unique_ptr<Table>>(std::move(table_v1)))));
143147

144148
auto metadata_location = std::format("{}v{}.metadata.json", table_location, 0);
145-
auto table = catalog_->RegisterTable(tableIdent, metadata_location);
149+
auto table = mock_catalog->RegisterTable(tableIdent, metadata_location);
146150
EXPECT_THAT(table, IsOk());
147151
ASSERT_TRUE(table.value()->current_snapshot().has_value());
148152
ASSERT_EQ(table.value()->current_snapshot().value()->snapshot_id, 3051729675574597004);

0 commit comments

Comments
 (0)