Skip to content

Commit

Permalink
Fix incorrect panic value when calling `ProjectionConfigurer.Delivery…
Browse files Browse the repository at this point in the history
…Policy()` with a `nil` policy.
  • Loading branch information
jmalloc committed Jul 16, 2024
1 parent c8b75ee commit 53caa25
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ The format is based on [Keep a Changelog], and this project adheres to
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## [Unreleased]

### Fixed

- Fixed incorrect panic value when calling
`ProjectionConfigurer.DeliveryPolicy()` with a `nil` policy.

## [0.13.0] - 2024-03-26

- **[BC]** Updated to Dogma v0.13.0
Expand Down
11 changes: 11 additions & 0 deletions projection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,16 @@ var _ = Describe("func FromProjection()", func() {
)
},
),
Entry(
"when the handler configures a nil delivery policy",
`delivery policy must not be nil`,
func(c dogma.ProjectionConfigurer) {
c.Identity("<name>", projectionKey)
c.Routes(
dogma.HandlesEvent[fixtures.MessageA](),
)
c.DeliveryPolicy(nil)
},
),
)
})
7 changes: 5 additions & 2 deletions projectionconfigurer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package configkit

import "github.com/dogmatiq/dogma"
import (
"github.com/dogmatiq/configkit/internal/validation"
"github.com/dogmatiq/dogma"
)

type projectionConfigurer struct {
handlerConfigurer
Expand All @@ -15,7 +18,7 @@ func (c *projectionConfigurer) Routes(routes ...dogma.ProjectionRoute) {

func (c *projectionConfigurer) DeliveryPolicy(p dogma.ProjectionDeliveryPolicy) {
if p == nil {
panic("delivery policy must not be nil")
validation.Panicf("delivery policy must not be nil")
}

c.deliveryPolicy = p
Expand Down

0 comments on commit 53caa25

Please sign in to comment.