Correlations: improve error handling (#87810)

Improve error handling
This commit is contained in:
Piotr Jamróz 2024-05-20 10:35:47 +02:00 committed by GitHub
parent e91136338a
commit d09f5abec9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View File

@ -82,10 +82,16 @@ func (s CorrelationsService) deleteCorrelation(ctx context.Context, cmd DeleteCo
}
deletedCount, err := session.Delete(&Correlation{UID: cmd.UID, SourceUID: cmd.SourceUID})
if err != nil {
return err
}
if deletedCount == 0 {
return ErrCorrelationNotFound
}
return err
return nil
})
}
@ -142,10 +148,16 @@ func (s CorrelationsService) updateCorrelation(ctx context.Context, cmd UpdateCo
}
updateCount, err := session.Where("uid = ? AND source_uid = ?", correlation.UID, correlation.SourceUID).Limit(1).Update(correlation)
if err != nil {
return err
}
if updateCount == 0 {
return ErrCorrelationNotFound
}
return err
return nil
})
if err != nil {

View File

@ -16,8 +16,6 @@ import (
)
func TestIntegrationUpdateCorrelation(t *testing.T) {
// TODO: #82520 Possibly a flaky test
t.Skip()
if testing.Short() {
t.Skip("skipping integration test")
}