Skip to content

Commit

Permalink
fix: return error on wrong update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorien Grönwald committed Jan 26, 2025
1 parent ee5bf13 commit 9bd8c83
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/service/domain/tree/handle_new_sensor_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (s *TreeService) HandleNewSensorData(ctx context.Context, event *entities.E
newTree, err := s.treeRepo.Update(ctx, t.ID, tree.WithWateringStatus(status))
if err != nil {
log.Error("failed to update tree with new watering status", "tree_id", t.ID, "watering_status", status, "err", err)
return err
}

slog.Info("updating tree watering status", "prev_status", t.WateringStatus, "new_status", status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestTreeService_HandleNewSensorData(t *testing.T) {
err := svc.HandleNewSensorData(context.Background(), &event)

// then
assert.NoError(t, err)
assert.ErrorIs(t, err, storage.ErrTreeNotFound)
select {
case <-ch:
t.Fatal("event was received. It should not have been sent")
Expand Down

0 comments on commit 9bd8c83

Please sign in to comment.