Skip to content

Commit

Permalink
Add tests for IsDisabled() methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Oct 15, 2024
1 parent 59b39f9 commit 09710f3
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 5 deletions.
32 changes: 31 additions & 1 deletion config/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestAggregate_Identity(t *testing.T) {
})
}

func TestAggregate_Routes(t *testing.T) {
func TestAggregate_RouteSet(t *testing.T) {
t.Run("it returns the normalized routes", func(t *testing.T) {
h := &AggregateMessageHandlerStub{
ConfigureFunc: func(c dogma.AggregateConfigurer) {
Expand Down Expand Up @@ -190,6 +190,36 @@ func TestAggregate_Routes(t *testing.T) {
})
}

func TestAggregate_IsDisabled(t *testing.T) {
disable := false

h := &AggregateMessageHandlerStub{
ConfigureFunc: func(c dogma.AggregateConfigurer) {
c.Identity("name", "19cb98d5-dd17-4daf-ae00-1b413b7b899a")
c.Routes(
dogma.HandlesCommand[CommandStub[TypeA]](),
dogma.RecordsEvent[EventStub[TypeA]](),
)
if disable {
c.Disable()
}
},
}

cfg := runtimeconfig.FromAggregate(h)

if cfg.IsDisabled() {
t.Fatal("did not expect handler to be disabled")
}

disable = true
cfg = runtimeconfig.FromAggregate(h)

if !cfg.IsDisabled() {
t.Fatal("expected handler to be disabled")
}
}

func TestAggregate_Interface(t *testing.T) {
h := &AggregateMessageHandlerStub{
ConfigureFunc: func(c dogma.AggregateConfigurer) {
Expand Down
2 changes: 1 addition & 1 deletion config/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestApplication_Identity(t *testing.T) {
})
}

func TestApplication_Routes(t *testing.T) {
func TestApplication_RouteSet(t *testing.T) {
t.Run("it returns the normalized routes", func(t *testing.T) {
app := &ApplicationStub{
ConfigureFunc: func(c dogma.ApplicationConfigurer) {
Expand Down
31 changes: 30 additions & 1 deletion config/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestIntegration_Identity(t *testing.T) {
})
}

func TestIntegration_Routes(t *testing.T) {
func TestIntegration_RouteSet(t *testing.T) {
t.Run("it returns the normalized routes", func(t *testing.T) {
h := &IntegrationMessageHandlerStub{
ConfigureFunc: func(c dogma.IntegrationConfigurer) {
Expand Down Expand Up @@ -186,6 +186,35 @@ func TestIntegration_Routes(t *testing.T) {
})
}

func TestIntegration_IsDisabled(t *testing.T) {
disable := false

h := &IntegrationMessageHandlerStub{
ConfigureFunc: func(c dogma.IntegrationConfigurer) {
c.Identity("name", "19cb98d5-dd17-4daf-ae00-1b413b7b899a")
c.Routes(
dogma.HandlesCommand[CommandStub[TypeA]](),
)
if disable {
c.Disable()
}
},
}

cfg := runtimeconfig.FromIntegration(h)

if cfg.IsDisabled() {
t.Fatal("did not expect handler to be disabled")
}

disable = true
cfg = runtimeconfig.FromIntegration(h)

if !cfg.IsDisabled() {
t.Fatal("expected handler to be disabled")
}
}

func TestIntegration_Interface(t *testing.T) {
h := &IntegrationMessageHandlerStub{
ConfigureFunc: func(c dogma.IntegrationConfigurer) {
Expand Down
32 changes: 31 additions & 1 deletion config/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestProcess_Identity(t *testing.T) {
})
}

func TestProcess_Routes(t *testing.T) {
func TestProcess_RouteSet(t *testing.T) {
t.Run("it returns the normalized routes", func(t *testing.T) {
h := &ProcessMessageHandlerStub{
ConfigureFunc: func(c dogma.ProcessConfigurer) {
Expand Down Expand Up @@ -182,6 +182,36 @@ func TestProcess_Routes(t *testing.T) {
})
}

func TestProcess_IsDisabled(t *testing.T) {
disable := false

h := &ProcessMessageHandlerStub{
ConfigureFunc: func(c dogma.ProcessConfigurer) {
c.Identity("name", "19cb98d5-dd17-4daf-ae00-1b413b7b899a")
c.Routes(
dogma.HandlesEvent[EventStub[TypeA]](),
dogma.ExecutesCommand[CommandStub[TypeA]](),
)
if disable {
c.Disable()
}
},
}

cfg := runtimeconfig.FromProcess(h)

if cfg.IsDisabled() {
t.Fatal("did not expect handler to be disabled")
}

disable = true
cfg = runtimeconfig.FromProcess(h)

if !cfg.IsDisabled() {
t.Fatal("expected handler to be disabled")
}
}

func TestProcess_Interface(t *testing.T) {
h := &ProcessMessageHandlerStub{
ConfigureFunc: func(c dogma.ProcessConfigurer) {
Expand Down
31 changes: 30 additions & 1 deletion config/projection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestProjection_Identity(t *testing.T) {
})
}

func TestProjection_Routes(t *testing.T) {
func TestProjection_RouteSet(t *testing.T) {
t.Run("it returns the normalized routes", func(t *testing.T) {
h := &ProjectionMessageHandlerStub{
ConfigureFunc: func(c dogma.ProjectionConfigurer) {
Expand Down Expand Up @@ -194,6 +194,35 @@ func TestProjection_Routes(t *testing.T) {
})
}

func TestProjection_IsDisabled(t *testing.T) {
disable := false

h := &ProjectionMessageHandlerStub{
ConfigureFunc: func(c dogma.ProjectionConfigurer) {
c.Identity("name", "19cb98d5-dd17-4daf-ae00-1b413b7b899a")
c.Routes(
dogma.HandlesEvent[EventStub[TypeA]](),
)
if disable {
c.Disable()
}
},
}

cfg := runtimeconfig.FromProjection(h)

if cfg.IsDisabled() {
t.Fatal("did not expect handler to be disabled")
}

disable = true
cfg = runtimeconfig.FromProjection(h)

if !cfg.IsDisabled() {
t.Fatal("expected handler to be disabled")
}
}

func TestProjection_Interface(t *testing.T) {
h := &ProjectionMessageHandlerStub{
ConfigureFunc: func(c dogma.ProjectionConfigurer) {
Expand Down

0 comments on commit 09710f3

Please sign in to comment.