Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
8a79d9e8f9
commit
cc9ecf5847
3 changed files with 58 additions and 3 deletions
|
|
@ -17,6 +17,7 @@ package sql
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
|
|
@ -73,11 +74,16 @@ func (s *sqlDatabase) DeletePoolByID(_ context.Context, poolID string) (err erro
|
|||
return errors.Wrap(err, "fetching pool by ID")
|
||||
}
|
||||
|
||||
defer func() {
|
||||
defer func(pool Pool) {
|
||||
if err == nil {
|
||||
s.sendNotify(common.PoolEntityType, common.DeleteOperation, pool)
|
||||
asParams, innerErr := s.sqlToCommonPool(pool)
|
||||
if innerErr == nil {
|
||||
s.sendNotify(common.PoolEntityType, common.DeleteOperation, asParams)
|
||||
} else {
|
||||
slog.With(slog.Any("error", innerErr)).ErrorContext(s.ctx, "error sending delete notification", "pool", poolID)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}(pool)
|
||||
|
||||
if q := s.conn.Unscoped().Delete(&pool); q.Error != nil {
|
||||
return errors.Wrap(q.Error, "removing pool")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue