updated tests

This commit is contained in:
Gani Georgiev
2024-10-18 12:23:18 +03:00
parent 5dbf975424
commit dbc074ee9a
2 changed files with 27 additions and 8 deletions

View File

@@ -141,7 +141,7 @@ func (app *BaseApp) delete(ctx context.Context, model Model, isForAuxDB bool) er
})
if deleteErr != nil {
errEvent := &ModelErrorEvent{ModelEvent: *event, Error: deleteErr}
errEvent.App = app
errEvent.App = app // replace with the initial app in case it was changed by the hook
hookErr := app.OnModelAfterDeleteError().Trigger(errEvent)
if hookErr != nil {
return errors.Join(deleteErr, hookErr)
@@ -332,7 +332,7 @@ func (app *BaseApp) create(ctx context.Context, model Model, withValidations boo
event.Model.MarkAsNew() // reset "new" state
errEvent := &ModelErrorEvent{ModelEvent: *event, Error: saveErr}
errEvent.App = app
errEvent.App = app // replace with the initial app in case it was changed by the hook
hookErr := app.OnModelAfterCreateError().Trigger(errEvent)
if hookErr != nil {
return errors.Join(saveErr, hookErr)
@@ -416,7 +416,7 @@ func (app *BaseApp) update(ctx context.Context, model Model, withValidations boo
})
if saveErr != nil {
errEvent := &ModelErrorEvent{ModelEvent: *event, Error: saveErr}
errEvent.App = app
errEvent.App = app // replace with the initial app in case it was changed by the hook
hookErr := app.OnModelAfterUpdateError().Trigger(errEvent)
if hookErr != nil {
return errors.Join(saveErr, hookErr)