1919
2020#include " iceberg/update/update_properties.h"
2121
22- #include " iceberg/table.h"
2322#include " iceberg/table_update.h"
2423#include " iceberg/test/matchers.h"
2524#include " iceberg/test/update_test_base.h"
@@ -28,11 +27,6 @@ namespace iceberg {
2827
2928class UpdatePropertiesTest : public UpdateTestBase {};
3029
31- TEST_F (UpdatePropertiesTest, EmptyUpdates) {
32- ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
33- EXPECT_THAT (update->Commit (), IsOk ());
34- }
35-
3630TEST_F (UpdatePropertiesTest, SetProperty) {
3731 ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
3832 update->Set (" key1" , " value1" ).Set (" key2" , " value2" );
@@ -43,7 +37,14 @@ TEST_F(UpdatePropertiesTest, SetProperty) {
4337}
4438
4539TEST_F (UpdatePropertiesTest, RemoveProperty) {
46- ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
40+ // First, add properties to remove
41+ ICEBERG_UNWRAP_OR_FAIL (auto setup_update, table_->NewUpdateProperties ());
42+ setup_update->Set (" key1" , " value1" ).Set (" key2" , " value2" );
43+ EXPECT_THAT (setup_update->Commit (), IsOk ());
44+
45+ // Reload and remove the properties
46+ ICEBERG_UNWRAP_OR_FAIL (auto reloaded, catalog_->LoadTable (table_ident_));
47+ ICEBERG_UNWRAP_OR_FAIL (auto update, reloaded->NewUpdateProperties ());
4748 update->Remove (" key1" ).Remove (" key2" );
4849
4950 ICEBERG_UNWRAP_OR_FAIL (auto result, update->Apply ());
@@ -69,6 +70,17 @@ TEST_F(UpdatePropertiesTest, RemoveThenSetSameKey) {
6970 EXPECT_THAT (result, HasErrorMessage (" already marked for removal" ));
7071}
7172
73+ TEST_F (UpdatePropertiesTest, SetAndRemoveDifferentKeys) {
74+ ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
75+ update->Set (" key1" , " value1" ).Remove (" key2" );
76+ EXPECT_THAT (update->Commit (), IsOk ());
77+
78+ ICEBERG_UNWRAP_OR_FAIL (auto reloaded, catalog_->LoadTable (table_ident_));
79+ const auto & props = reloaded->properties ().configs ();
80+ EXPECT_EQ (props.at (" key1" ), " value1" );
81+ EXPECT_FALSE (props.contains (" key2" ));
82+ }
83+
7284TEST_F (UpdatePropertiesTest, UpgradeFormatVersionValid) {
7385 ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
7486 update->Set (" format-version" , " 2" );
@@ -108,33 +120,20 @@ TEST_F(UpdatePropertiesTest, UpgradeFormatVersionUnsupported) {
108120}
109121
110122TEST_F (UpdatePropertiesTest, CommitSuccess) {
123+ ICEBERG_UNWRAP_OR_FAIL (auto empty_update, table_->NewUpdateProperties ());
124+ EXPECT_THAT (empty_update->Commit (), IsOk ());
125+
111126 ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
112127 update->Set (" new.property" , " new.value" );
128+ update->Set (" format-version" , " 3" );
113129
114130 EXPECT_THAT (update->Commit (), IsOk ());
115131
116132 ICEBERG_UNWRAP_OR_FAIL (auto reloaded, catalog_->LoadTable (table_ident_));
117133 const auto & props = reloaded->properties ().configs ();
118134 EXPECT_EQ (props.at (" new.property" ), " new.value" );
119- }
120-
121- TEST_F (UpdatePropertiesTest, FluentInterface) {
122- ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
123- auto & ref = update->Set (" key1" , " value1" ).Remove (" key2" );
124-
125- EXPECT_EQ (&ref, update.get ());
126- EXPECT_THAT (update->Apply (), IsOk ());
127- }
128-
129- TEST_F (UpdatePropertiesTest, SetAndRemoveDifferentKeys) {
130- ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateProperties ());
131- update->Set (" key1" , " value1" ).Remove (" key2" );
132- EXPECT_THAT (update->Commit (), IsOk ());
133-
134- ICEBERG_UNWRAP_OR_FAIL (auto reloaded, catalog_->LoadTable (table_ident_));
135- const auto & props = reloaded->properties ().configs ();
136- EXPECT_EQ (props.at (" key1" ), " value1" );
137- EXPECT_FALSE (props.contains (" key2" ));
135+ const auto & format_version = reloaded->metadata ()->format_version ;
136+ EXPECT_EQ (format_version, 3 );
138137}
139138
140139} // namespace iceberg
0 commit comments