Skip to content

Commit

Permalink
WIP [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Aug 18, 2024
1 parent 75cf72c commit 3aca422
Show file tree
Hide file tree
Showing 57 changed files with 564 additions and 492 deletions.
6 changes: 3 additions & 3 deletions action.advancetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/dogmatiq/configkit"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/dogma/fixtures"
"github.com/dogmatiq/enginekit/enginetest/stubs"
. "github.com/dogmatiq/testkit"
"github.com/dogmatiq/testkit/engine"
"github.com/dogmatiq/testkit/fact"
Expand All @@ -18,15 +18,15 @@ import (

var _ = g.Describe("func AdvanceTime()", func() {
var (
app *Application
app *stubs.ApplicationStub
t *testingmock.T
startTime time.Time
buf *fact.Buffer
test *Test
)

g.BeforeEach(func() {
app = &Application{
app = &stubs.ApplicationStub{
ConfigureFunc: func(c dogma.ApplicationConfigurer) {
c.Identity("<app>", "140ca29b-7a05-4f26-968b-6285255e6d8a")
},
Expand Down
35 changes: 17 additions & 18 deletions action.call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"time"

"github.com/dogmatiq/configkit"
. "github.com/dogmatiq/configkit/fixtures"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/dogma/fixtures"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
. "github.com/dogmatiq/testkit"
"github.com/dogmatiq/testkit/engine"
"github.com/dogmatiq/testkit/envelope"
Expand All @@ -21,37 +20,37 @@ import (

var _ = g.Describe("func Call()", func() {
var (
app *Application
app *ApplicationStub
t *testingmock.T
startTime time.Time
buf *fact.Buffer
test *Test
)

g.BeforeEach(func() {
app = &Application{
app = &ApplicationStub{
ConfigureFunc: func(c dogma.ApplicationConfigurer) {
c.Identity("<app>", "b51cde16-aaec-4d75-ae14-06282e3a72c8")
c.RegisterAggregate(&AggregateMessageHandler{

c.RegisterAggregate(&AggregateMessageHandlerStub{
ConfigureFunc: func(c dogma.AggregateConfigurer) {
c.Identity("<aggregate>", "832d78d7-a006-414f-b6d7-3153aa7c9ab8")
c.Routes(
dogma.HandlesCommand[MessageC](),
dogma.RecordsEvent[MessageE](),
dogma.HandlesCommand[CommandStub[TypeA]](),
dogma.RecordsEvent[EventStub[TypeA]](),
)
},
RouteCommandToInstanceFunc: func(
dogma.Command,
) string {
RouteCommandToInstanceFunc: func(dogma.Command) string {
return "<instance>"
},
})
c.RegisterProcess(&ProcessMessageHandler{

c.RegisterProcess(&ProcessMessageHandlerStub{
ConfigureFunc: func(c dogma.ProcessConfigurer) {
c.Identity("<process>", "b64cdd19-782e-4e4e-9e5f-a95a943d6340")
c.Routes(
dogma.HandlesEvent[MessageE](),
dogma.ExecutesCommand[MessageC](),
dogma.HandlesEvent[EventStub[TypeA]](),
dogma.ExecutesCommand[CommandStub[TypeA]](),
)
},
RouteEventToInstanceFunc: func(
Expand Down Expand Up @@ -85,7 +84,7 @@ var _ = g.Describe("func Call()", func() {
Call(func() {
e.ExecuteCommand(
context.Background(),
MessageC1,
CommandA1,
)
}),
)
Expand All @@ -96,8 +95,8 @@ var _ = g.Describe("func Call()", func() {
MessageID: "1",
CausationID: "1",
CorrelationID: "1",
Message: MessageC1,
Type: MessageCType,
Message: CommandA1,
Type: message.TypeOf(CommandA1),
Role: message.CommandRole,
CreatedAt: startTime,
},
Expand All @@ -120,10 +119,10 @@ var _ = g.Describe("func Call()", func() {
Call(func() {
e.ExecuteCommand(
context.Background(),
MessageC1,
CommandA1,
)
}),
ToExecuteCommand(MessageC1),
ToExecuteCommand(CommandA1),
)
})

Expand Down
32 changes: 16 additions & 16 deletions action.dispatch.command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"time"

"github.com/dogmatiq/configkit"
. "github.com/dogmatiq/configkit/fixtures"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/dogma/fixtures"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
. "github.com/dogmatiq/testkit"
"github.com/dogmatiq/testkit/engine"
"github.com/dogmatiq/testkit/envelope"
Expand All @@ -20,23 +19,24 @@ import (

var _ = g.Describe("func ExecuteCommand()", func() {
var (
app *Application
app *ApplicationStub
t *testingmock.T
startTime time.Time
buf *fact.Buffer
test *Test
)

g.BeforeEach(func() {
app = &Application{
app = &ApplicationStub{
ConfigureFunc: func(c dogma.ApplicationConfigurer) {
c.Identity("<app>", "a84b2620-4675-4024-b55b-cd5dbeb6e293")
c.RegisterAggregate(&AggregateMessageHandler{

c.RegisterAggregate(&AggregateMessageHandlerStub{
ConfigureFunc: func(c dogma.AggregateConfigurer) {
c.Identity("<aggregate>", "d1cf3af1-6c20-4125-8e68-192a6075d0b4")
c.Routes(
dogma.HandlesCommand[MessageC](),
dogma.RecordsEvent[MessageE](),
dogma.HandlesCommand[EventStub[TypeA]](),
dogma.RecordsEvent[EventStub[TypeA]](),
)
},
RouteCommandToInstanceFunc: func(
Expand Down Expand Up @@ -64,7 +64,7 @@ var _ = g.Describe("func ExecuteCommand()", func() {

g.It("dispatches the message", func() {
test.Prepare(
ExecuteCommand(MessageC1),
ExecuteCommand(CommandA1),
)

Expect(buf.Facts()).To(ContainElement(
Expand All @@ -73,8 +73,8 @@ var _ = g.Describe("func ExecuteCommand()", func() {
MessageID: "1",
CausationID: "1",
CorrelationID: "1",
Message: MessageC1,
Type: MessageCType,
Message: CommandA1,
Type: message.TypeOf(CommandA1),
Role: message.CommandRole,
CreatedAt: startTime,
},
Expand All @@ -94,7 +94,7 @@ var _ = g.Describe("func ExecuteCommand()", func() {
t.FailSilently = true

test.Prepare(
ExecuteCommand(MessageX1),
ExecuteCommand(CommandX1),
)

Expect(t.Failed()).To(BeTrue())
Expand All @@ -107,7 +107,7 @@ var _ = g.Describe("func ExecuteCommand()", func() {
t.FailSilently = true

test.Prepare(
ExecuteCommand(MessageE1),
ExecuteCommand(EventA1),
)

Expect(t.Failed()).To(BeTrue())
Expand All @@ -120,16 +120,16 @@ var _ = g.Describe("func ExecuteCommand()", func() {
t.FailSilently = true

test.Expect(
ExecuteCommand(MessageC1),
ToExecuteCommand(MessageC1),
ExecuteCommand(CommandA1),
ToExecuteCommand(CommandA1),
)

Expect(t.Failed()).To(BeTrue())
})

g.It("produces the expected caption", func() {
test.Prepare(
ExecuteCommand(MessageC1),
ExecuteCommand(CommandA1),
)

Expect(t.Logs).To(ContainElement(
Expand All @@ -144,7 +144,7 @@ var _ = g.Describe("func ExecuteCommand()", func() {
})

g.It("captures the location that the action was created", func() {
act := executeCommand(MessageC1)
act := executeCommand(CommandA1)
Expect(act.Location()).To(MatchAllFields(
Fields{
"Func": Equal("github.com/dogmatiq/testkit_test.executeCommand"),
Expand Down
34 changes: 17 additions & 17 deletions action.dispatch.event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"time"

"github.com/dogmatiq/configkit"
. "github.com/dogmatiq/configkit/fixtures"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/dogma/fixtures"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
. "github.com/dogmatiq/testkit"
"github.com/dogmatiq/testkit/engine"
"github.com/dogmatiq/testkit/envelope"
Expand All @@ -21,23 +20,24 @@ import (

var _ = g.Describe("func RecordEvent()", func() {
var (
app *Application
app *ApplicationStub
t *testingmock.T
startTime time.Time
buf *fact.Buffer
test *Test
)

g.BeforeEach(func() {
app = &Application{
app = &ApplicationStub{
ConfigureFunc: func(c dogma.ApplicationConfigurer) {
c.Identity("<app>", "38408e83-e8eb-4f82-abe1-7fa02cee0657")
c.RegisterProcess(&ProcessMessageHandler{

c.RegisterProcess(&ProcessMessageHandlerStub{
ConfigureFunc: func(c dogma.ProcessConfigurer) {
c.Identity("<process>", "1c0dd111-fe12-4dee-a8bc-64abea1dce8f")
c.Routes(
dogma.HandlesEvent[MessageE](),
dogma.ExecutesCommand[MessageC](),
dogma.HandlesEvent[EventStub[TypeA]](),
dogma.ExecutesCommand[CommandStub[TypeA]](),
)
},
RouteEventToInstanceFunc: func(
Expand Down Expand Up @@ -66,7 +66,7 @@ var _ = g.Describe("func RecordEvent()", func() {

g.It("dispatches the message", func() {
test.Prepare(
RecordEvent(MessageE1),
RecordEvent(EventA1),
)

Expect(buf.Facts()).To(ContainElement(
Expand All @@ -75,8 +75,8 @@ var _ = g.Describe("func RecordEvent()", func() {
MessageID: "1",
CausationID: "1",
CorrelationID: "1",
Message: MessageE1,
Type: MessageEType,
Message: EventA1,
Type: message.TypeOf(EventA1),
Role: message.EventRole,
CreatedAt: startTime,
},
Expand All @@ -96,20 +96,20 @@ var _ = g.Describe("func RecordEvent()", func() {
t.FailSilently = true

test.Prepare(
RecordEvent(MessageX1),
RecordEvent(EventX1),
)

Expect(t.Failed()).To(BeTrue())
Expect(t.Logs).To(ContainElement(
"cannot record event, fixtures.MessageX is a not a recognized message type",
"cannot record event, stubs.EventStub[TypeX] is a not a recognized message type",
))
})

g.It("fails the test if the message type is not an event", func() {
t.FailSilently = true

test.Prepare(
RecordEvent(MessageC1),
RecordEvent(CommandA1),
)

Expect(t.Failed()).To(BeTrue())
Expand All @@ -122,16 +122,16 @@ var _ = g.Describe("func RecordEvent()", func() {
t.FailSilently = true

test.Expect(
RecordEvent(MessageE1),
ToRecordEvent(MessageE1),
RecordEvent(EventA1),
ToRecordEvent(EventA1),
)

Expect(t.Failed()).To(BeTrue())
})

g.It("produces the expected caption", func() {
test.Prepare(
RecordEvent(MessageE1),
RecordEvent(EventA1),
)

Expect(t.Logs).To(ContainElement(
Expand All @@ -146,7 +146,7 @@ var _ = g.Describe("func RecordEvent()", func() {
})

g.It("captures the location that the action was created", func() {
act := recordEvent(MessageE1)
act := recordEvent(EventA1)
Expect(act.Location()).To(MatchAllFields(
Fields{
"Func": Equal("github.com/dogmatiq/testkit_test.recordEvent"),
Expand Down
Loading

0 comments on commit 3aca422

Please sign in to comment.