Skip to content

Commit 598768c

Browse files
committed
add test
1 parent 828ad81 commit 598768c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

test/metadata_serde_test.cc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,21 @@ TEST_F(MetadataSerdeTest, DeserializeV2Valid) {
106106
/*optional=*/false);
107107
schema_fields.emplace_back(/*field_id=*/3, "z", iceberg::int64(),
108108
/*optional=*/false);
109-
auto expected_schema =
110-
std::make_shared<Schema>(std::move(schema_fields), /*schema_id=*/1);
109+
auto expected_schema = std::make_shared<Schema>(schema_fields, /*schema_id=*/1);
111110
auto schema = metadata->Schema();
112111
ASSERT_TRUE(schema.has_value());
113112
EXPECT_EQ(*(schema.value().get()), *expected_schema);
114113

114+
auto schema_v1 = metadata->SchemaById(1);
115+
ASSERT_TRUE(schema_v1.has_value());
116+
EXPECT_EQ(*(schema_v1.value().get()), *expected_schema);
117+
118+
auto expected_schema_v0 = std::make_shared<Schema>(
119+
std::vector<SchemaField>{schema_fields.at(0)}, /*schema_id=*/0);
120+
auto schema_v0 = metadata->SchemaById(0);
121+
ASSERT_TRUE(schema_v0.has_value());
122+
EXPECT_EQ(*(schema_v0.value().get()), *expected_schema_v0);
123+
115124
// Compare partition spec
116125
EXPECT_EQ(metadata->default_spec_id, 0);
117126
std::vector<PartitionField> partition_fields;
@@ -164,6 +173,13 @@ TEST_F(MetadataSerdeTest, DeserializeV2Valid) {
164173
for (size_t i = 0; i < expected_snapshots.size(); ++i) {
165174
EXPECT_EQ(*metadata->snapshots[i], expected_snapshots[i]);
166175
}
176+
auto snapshot_v0 = metadata->SnapshotById(3051729675574597004);
177+
ASSERT_TRUE(snapshot_v0.has_value());
178+
EXPECT_EQ(*snapshot_v0.value(), expected_snapshots[0]);
179+
180+
auto snapshot_v1 = metadata->SnapshotById(3055729675574597004);
181+
ASSERT_TRUE(snapshot_v1.has_value());
182+
EXPECT_EQ(*snapshot_v1.value(), expected_snapshots[1]);
167183

168184
// Compare snapshot logs
169185
std::vector<SnapshotLogEntry> expected_snapshot_log{

0 commit comments

Comments
 (0)