Add more tests

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-06-18 19:28:34 +00:00
parent 8a79d9e8f9
commit cc9ecf5847
3 changed files with 58 additions and 3 deletions

View file

@ -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")