Revanth14 commented on code in PR #1285:
URL: https://github.com/apache/iceberg-go/pull/1285#discussion_r3470607739


##########
catalog/glue/glue_test.go:
##########
@@ -451,6 +459,116 @@ func TestGlueDropTable(t *testing.T) {
        assert.NoError(err)
 }
 
+func TestGluePurgeTable(t *testing.T) {
+       assert := require.New(t)
+       ctx := context.Background()
+       tableLocation := filepath.Join(t.TempDir(), "warehouse", 
"test_database", "test_table")
+       metadataLocation, dataFile := writeGluePurgeTableFiles(t, tableLocation)
+       glueTable := gluePurgeTable(metadataLocation)
+
+       mockGlueSvc := &mockGlueClient{}
+       mockGlueSvc.On("GetTable", mock.Anything, &glue.GetTableInput{
+               DatabaseName: aws.String("test_database"),
+               Name:         aws.String("test_table"),
+       }, mock.Anything).Return(&glue.GetTableOutput{Table: &glueTable}, 
nil).Twice()
+       mockGlueSvc.On("DeleteTable", mock.Anything, &glue.DeleteTableInput{
+               DatabaseName: aws.String("test_database"),
+               Name:         aws.String("test_table"),
+       }, mock.Anything).Return(&glue.DeleteTableOutput{}, nil).Once()
+
+       glueCatalog := &Catalog{glueSvc: mockGlueSvc}
+
+       assert.NoError(glueCatalog.PurgeTable(ctx, 
TableIdentifier("test_database", "test_table")))
+       assert.NoFileExists(metadataLocation)
+       assert.NoFileExists(dataFile)
+       mockGlueSvc.AssertExpectations(t)
+}
+
+func TestGluePurgeTableSwallowsPurgeFilesError(t *testing.T) {
+       assert := require.New(t)
+       ctx := context.Background()
+       const scheme = "gluepurgefail"
+       failingFS := failRemoveIO{MemFS: iceio.NewMemFS(), err: 
errGluePurgeRemove}
+       iceio.Register(scheme, func(context.Context, *url.URL, 
map[string]string) (iceio.IO, error) {
+               return failingFS, nil
+       })
+       t.Cleanup(func() { iceio.Unregister(scheme) })
+
+       tableLocation := scheme + "://bucket/test_database/test_table"
+       metadataLocation := tableLocation + "/metadata/v1.metadata.json"
+       dataFile := tableLocation + "/data/file.parquet"
+       writeGluePurgeTableMetadata(t, failingFS, tableLocation, 
metadataLocation)
+       require.NoError(t, failingFS.WriteFile(dataFile, []byte("data")))
+       glueTable := gluePurgeTable(metadataLocation)
+
+       mockGlueSvc := &mockGlueClient{}
+       mockGlueSvc.On("GetTable", mock.Anything, &glue.GetTableInput{
+               DatabaseName: aws.String("test_database"),
+               Name:         aws.String("test_table"),
+       }, mock.Anything).Return(&glue.GetTableOutput{Table: &glueTable}, 
nil).Twice()
+       mockGlueSvc.On("DeleteTable", mock.Anything, &glue.DeleteTableInput{
+               DatabaseName: aws.String("test_database"),
+               Name:         aws.String("test_table"),
+       }, mock.Anything).Return(&glue.DeleteTableOutput{}, nil).Once()
+
+       var logs bytes.Buffer
+       originalLogOutput := log.Writer()
+       log.SetOutput(&logs)
+       t.Cleanup(func() { log.SetOutput(originalLogOutput) })
+
+       glueCatalog := &Catalog{glueSvc: mockGlueSvc}
+
+       assert.NoError(glueCatalog.PurgeTable(ctx, 
TableIdentifier("test_database", "test_table")))
+       assert.Contains(logs.String(), "failed to purge files")

Review Comment:
   Updated this to anchor on the real warning path instead of the loose 
substring. The assertions now check `WARNING: dropped table`, the table 
identifier pieces, and the injected purge error, so the log match is tied to 
this specific `PurgeTable` call.
   
   The test is kept non-parallel while redirecting the process-global logger.



-- 
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]

Reply via email to