diff --git a/static/app_test.go b/static/app_test.go index 528bf791..088f3f66 100644 --- a/static/app_test.go +++ b/static/app_test.go @@ -169,31 +169,6 @@ var _ = Describe("func FromPackages() (application detection)", func() { }) }) - When("a handler with a non-pointer methodset is registered as a pointer", func() { - It("includes the handler in the application configuration", func() { - cfg := packages.Config{ - Mode: packages.LoadAllSyntax, - Dir: "testdata/apps/pointer-handler-with-non-pointer-methodset", - } - - pkgs := loadPackages(cfg) - - apps := FromPackages(pkgs) - Expect(apps).To(HaveLen(1)) - Expect(apps[0].Handlers().Aggregates()).To(HaveLen(1)) - - a := apps[0].Handlers().Aggregates()[0] - Expect(a.Identity()).To( - Equal( - configkit.Identity{ - Name: "", - Key: "dad3b670-0852-4711-9efb-af25679734ee", - }, - ), - ) - }) - }) - When("an application in the package has multiple handlers", func() { It("returns all messages consumed or produced by all handlers", func() { cfg := packages.Config{ diff --git a/static/handler_test.go b/static/handler_test.go index 4f7ae7e7..72a1f697 100644 --- a/static/handler_test.go +++ b/static/handler_test.go @@ -856,11 +856,11 @@ var _ = Describe("func FromPackages() (handler analysis)", func() { }) }) - When("the application contains handlers registered as pointers with method receivers passed by values", func() { - It("correctly returns configurations for such handlers", func() { + When("a handler with a non-pointer methodset is registered as a pointer", func() { + It("includes the handler in the application configuration", func() { cfg := packages.Config{ Mode: packages.LoadAllSyntax, - Dir: "testdata/handlers/non-pointer-registered-as-pointer", + Dir: "testdata/handlers/pointer-handler-with-non-pointer-methodset", } pkgs := loadPackages(cfg) @@ -883,7 +883,7 @@ var _ = Describe("func FromPackages() (handler analysis)", func() { ) Expect(aggregate.TypeName()).To( Equal( - "*github.com/dogmatiq/configkit/static/testdata/handlers/non-pointer-registered-as-pointer.AggregateHandler", + "*github.com/dogmatiq/configkit/static/testdata/handlers/pointer-handler-with-non-pointer-methodset.AggregateHandler", ), ) Expect(aggregate.HandlerType()).To(Equal(configkit.AggregateHandlerType)) @@ -912,7 +912,7 @@ var _ = Describe("func FromPackages() (handler analysis)", func() { ) Expect(process.TypeName()).To( Equal( - "*github.com/dogmatiq/configkit/static/testdata/handlers/non-pointer-registered-as-pointer.ProcessHandler", + "*github.com/dogmatiq/configkit/static/testdata/handlers/pointer-handler-with-non-pointer-methodset.ProcessHandler", ), ) Expect(process.HandlerType()).To(Equal(configkit.ProcessHandlerType)) @@ -945,7 +945,7 @@ var _ = Describe("func FromPackages() (handler analysis)", func() { ) Expect(projection.TypeName()).To( Equal( - "*github.com/dogmatiq/configkit/static/testdata/handlers/non-pointer-registered-as-pointer.ProjectionHandler", + "*github.com/dogmatiq/configkit/static/testdata/handlers/pointer-handler-with-non-pointer-methodset.ProjectionHandler", ), ) Expect(projection.HandlerType()).To(Equal(configkit.ProjectionHandlerType)) @@ -971,7 +971,7 @@ var _ = Describe("func FromPackages() (handler analysis)", func() { ) Expect(integration.TypeName()).To( Equal( - "*github.com/dogmatiq/configkit/static/testdata/handlers/non-pointer-registered-as-pointer.IntegrationHandler", + "*github.com/dogmatiq/configkit/static/testdata/handlers/pointer-handler-with-non-pointer-methodset.IntegrationHandler", ), ) Expect(integration.HandlerType()).To(Equal(configkit.IntegrationHandlerType)) diff --git a/static/testdata/apps/pointer-handler-with-non-pointer-methodset/aggregate.go b/static/testdata/apps/pointer-handler-with-non-pointer-methodset/aggregate.go deleted file mode 100644 index a473282b..00000000 --- a/static/testdata/apps/pointer-handler-with-non-pointer-methodset/aggregate.go +++ /dev/null @@ -1,46 +0,0 @@ -package app - -import ( - "github.com/dogmatiq/dogma" - "github.com/dogmatiq/dogma/fixtures" -) - -// Aggregate is an aggregate used for testing. -type Aggregate struct{} - -// ApplyEvent updates the aggregate instance to reflect the occurrence of an -// event that was recorded against this instance. -func (Aggregate) ApplyEvent(m dogma.Message) {} - -// AggregateHandler is a test implementation of dogma.AggregateMessageHandler. -type AggregateHandler struct{} - -// New returns a new account instance. -func (AggregateHandler) New() dogma.AggregateRoot { - return Aggregate{} -} - -// Configure configures the behavior of the engine as it relates to this -// handler. -func (AggregateHandler) Configure(c dogma.AggregateConfigurer) { - c.Identity("", "dad3b670-0852-4711-9efb-af25679734ee") - - c.Routes( - dogma.HandlesCommand[fixtures.MessageA](), - dogma.RecordsEvent[fixtures.MessageB](), - ) -} - -// RouteCommandToInstance returns the ID of the aggregate instance that is -// targetted by m. -func (AggregateHandler) RouteCommandToInstance(m dogma.Message) string { - return "" -} - -// HandleCommand handles a command message that has been routed to this handler. -func (AggregateHandler) HandleCommand( - r dogma.AggregateRoot, - s dogma.AggregateCommandScope, - m dogma.Message, -) { -} diff --git a/static/testdata/apps/pointer-handler-with-non-pointer-methodset/app.go b/static/testdata/apps/pointer-handler-with-non-pointer-methodset/app.go deleted file mode 100644 index be98f7b5..00000000 --- a/static/testdata/apps/pointer-handler-with-non-pointer-methodset/app.go +++ /dev/null @@ -1,16 +0,0 @@ -package app - -import ( - "github.com/dogmatiq/dogma" -) - -// App implements dogma.Application interface. -type App struct{} - -// Configure configures the behavior of the engine as it relates to this -// application. -func (a App) Configure(c dogma.ApplicationConfigurer) { - c.Identity("", "dc3ef830-ee59-472a-a8d7-523f0570a918") - - c.RegisterAggregate(&AggregateHandler{}) -} diff --git a/static/testdata/handlers/non-pointer-registered-as-pointer/aggregate.go b/static/testdata/handlers/pointer-handler-with-non-pointer-methodset/aggregate.go similarity index 100% rename from static/testdata/handlers/non-pointer-registered-as-pointer/aggregate.go rename to static/testdata/handlers/pointer-handler-with-non-pointer-methodset/aggregate.go diff --git a/static/testdata/handlers/non-pointer-registered-as-pointer/app.go b/static/testdata/handlers/pointer-handler-with-non-pointer-methodset/app.go similarity index 100% rename from static/testdata/handlers/non-pointer-registered-as-pointer/app.go rename to static/testdata/handlers/pointer-handler-with-non-pointer-methodset/app.go diff --git a/static/testdata/handlers/non-pointer-registered-as-pointer/integration.go b/static/testdata/handlers/pointer-handler-with-non-pointer-methodset/integration.go similarity index 100% rename from static/testdata/handlers/non-pointer-registered-as-pointer/integration.go rename to static/testdata/handlers/pointer-handler-with-non-pointer-methodset/integration.go diff --git a/static/testdata/handlers/non-pointer-registered-as-pointer/process.go b/static/testdata/handlers/pointer-handler-with-non-pointer-methodset/process.go similarity index 100% rename from static/testdata/handlers/non-pointer-registered-as-pointer/process.go rename to static/testdata/handlers/pointer-handler-with-non-pointer-methodset/process.go diff --git a/static/testdata/handlers/non-pointer-registered-as-pointer/projection.go b/static/testdata/handlers/pointer-handler-with-non-pointer-methodset/projection.go similarity index 100% rename from static/testdata/handlers/non-pointer-registered-as-pointer/projection.go rename to static/testdata/handlers/pointer-handler-with-non-pointer-methodset/projection.go