smaheshwar-pltr commented on code in PR #16796:
URL: https://github.com/apache/iceberg/pull/16796#discussion_r3591575752
##########
core/src/test/java/org/apache/iceberg/TestCatalogUtil.java:
##########
@@ -320,6 +325,76 @@ public void noFailureWhenBulkDeletingMetadataFiles() {
.doesNotThrowAnyException();
}
+ @Test
+ public void deletesSupersededMetadataFileWhenPreviousVersionsMaxIsZero() {
+ FileIO io = mock(FileIO.class);
+
+ TableMetadata.MetadataLogEntry entry1 =
+ new TableMetadata.MetadataLogEntry(
+ System.currentTimeMillis(), "s3://bucket/metadata/v1.json");
+
+ TableMetadata base = mock(TableMetadata.class);
+ TableMetadata metadata = mock(TableMetadata.class);
+
+ when(metadata.propertyAsBoolean(
+ eq(TableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLED),
anyBoolean()))
+ .thenReturn(true);
+ when(base.previousFiles()).thenReturn(ImmutableList.of(entry1));
+
when(base.metadataFileLocation()).thenReturn("s3://bucket/metadata/v2.json");
+ when(metadata.previousFiles()).thenReturn(ImmutableList.of());
Review Comment:
> The guard that's actually load-bearing here (don't delete the current
metadata file) never gets exercised.
This isn't actually what we're testing in this test, and stubbing doesn't
change that - this behaviour is what
`doesNotDeleteCurrentMetadataFileWhenBaseEqualsMetadata` is for.
I do like returning a "v3.json" file though, made that change now - thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]