diff --git a/database/sql/jobs.go b/database/sql/jobs.go index 2dfadf13..887e041f 100644 --- a/database/sql/jobs.go +++ b/database/sql/jobs.go @@ -142,11 +142,10 @@ func (s *sqlDatabase) LockJob(_ context.Context, jobID int64, entityID string) e } asParams, err := sqlWorkflowJobToParamsJob(workflowJob) - if err == nil { - s.sendNotify(common.JobEntityType, common.UpdateOperation, asParams) - } else { - slog.With(slog.Any("error", err)).Error("failed to convert job to params") + if err != nil { + return errors.Wrap(err, "converting job") } + s.sendNotify(common.JobEntityType, common.UpdateOperation, asParams) return nil } @@ -172,11 +171,10 @@ func (s *sqlDatabase) BreakLockJobIsQueued(_ context.Context, jobID int64) (err return errors.Wrap(err, "saving job") } asParams, err := sqlWorkflowJobToParamsJob(workflowJob) - if err == nil { - s.sendNotify(common.JobEntityType, common.UpdateOperation, asParams) - } else { - slog.With(slog.Any("error", err)).Error("failed to convert job to params") + if err != nil { + return errors.Wrap(err, "converting job") } + s.sendNotify(common.JobEntityType, common.UpdateOperation, asParams) return nil } @@ -206,11 +204,10 @@ func (s *sqlDatabase) UnlockJob(_ context.Context, jobID int64, entityID string) } asParams, err := sqlWorkflowJobToParamsJob(workflowJob) - if err == nil { - s.sendNotify(common.JobEntityType, common.UpdateOperation, asParams) - } else { - slog.With(slog.Any("error", err)).Error("failed to convert job to params") + if err != nil { + return errors.Wrap(err, "converting job") } + s.sendNotify(common.JobEntityType, common.UpdateOperation, asParams) return nil } diff --git a/database/watcher/watcher_store_test.go b/database/watcher/watcher_store_test.go index b6a5bcb2..a0845b9c 100644 --- a/database/watcher/watcher_store_test.go +++ b/database/watcher/watcher_store_test.go @@ -54,6 +54,10 @@ func (s *WatcherStoreTestSuite) TestJobWatcher() { Operation: common.CreateOperation, Payload: job, }, event) + asJob, ok := event.Payload.(params.Job) + s.Require().True(ok) + s.Require().Equal(job.ID, int64(1)) + s.Require().Equal(asJob.ID, int64(1)) case <-time.After(1 * time.Second): s.T().Fatal("expected payload not received") } @@ -190,6 +194,10 @@ func (s *WatcherStoreTestSuite) TestInstanceWatcher() { Operation: common.CreateOperation, Payload: instance, }, event) + asInstance, ok := event.Payload.(params.Instance) + s.Require().True(ok) + s.Require().Equal(instance.Name, "test-instance") + s.Require().Equal(asInstance.Name, "test-instance") case <-time.After(1 * time.Second): s.T().Fatal("expected payload not received") } @@ -282,6 +290,10 @@ func (s *WatcherStoreTestSuite) TestPoolWatcher() { Operation: common.CreateOperation, Payload: pool, }, event) + asPool, ok := event.Payload.(params.Pool) + s.Require().True(ok) + s.Require().Equal(pool.Image, "test-image") + s.Require().Equal(asPool.Image, "test-image") case <-time.After(1 * time.Second): s.T().Fatal("expected payload not received") }