Skip to content

Commit

Permalink
Use generic message stubs in static analysis tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Aug 22, 2024
1 parent 6d9e342 commit 27b217c
Show file tree
Hide file tree
Showing 69 changed files with 586 additions and 2,327 deletions.
140 changes: 0 additions & 140 deletions static/adaptor_test.go

This file was deleted.

95 changes: 95 additions & 0 deletions static/app_aliased_handlers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package static_test

import (
"os"

"github.com/dogmatiq/configkit"
. "github.com/dogmatiq/configkit/static"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("registering handlers using a type alias", func() {
goDebugBefore := os.Getenv("GODEBUG")

BeforeEach(func() {
// Set the GODEBUG environment variable to enable type alias support.
//
// TODO: Remove this setting once the package is migrated to Go 1.23
// that generates `types.Alias` types by default.
os.Setenv("GODEBUG", "gotypesalias=1")
})

AfterEach(func() {
os.Setenv("GODEBUG", goDebugBefore)
})

It("it reports the aliased type name", func() {
apps := FromDir("testdata/apps/aliased-handlers")
Expect(apps).To(HaveLen(1))
Expect(apps[0].Handlers().Aggregates()).To(HaveLen(1))
Expect(apps[0].Handlers().Processes()).To(HaveLen(1))
Expect(apps[0].Handlers().Projections()).To(HaveLen(1))
Expect(apps[0].Handlers().Integrations()).To(HaveLen(1))

aggregate := apps[0].Handlers().Aggregates()[0]
Expect(aggregate.Identity()).To(
Equal(
configkit.Identity{
Name: "<aggregate>",
Key: "92623de9-c9cf-42f3-8338-33c50eeb06fb",
},
),
)
Expect(aggregate.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/aliased-handlers.AggregateHandlerAlias",
),
)

process := apps[0].Handlers().Processes()[0]
Expect(process.Identity()).To(
Equal(
configkit.Identity{
Name: "<process>",
Key: "ad9d6955-893a-4d8d-a26e-e25886b113b2",
},
),
)
Expect(process.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/aliased-handlers.ProcessHandlerAlias",
),
)

projection := apps[0].Handlers().Projections()[0]
Expect(projection.Identity()).To(
Equal(
configkit.Identity{
Name: "<projection>",
Key: "d012b7ed-3c4b-44db-9276-7bbc90fb54fd",
},
),
)
Expect(projection.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/aliased-handlers.ProjectionHandlerAlias",
),
)

integration := apps[0].Handlers().Integrations()[0]
Expect(integration.Identity()).To(
Equal(
configkit.Identity{
Name: "<integration>",
Key: "4d8cd3f5-21dc-475b-a8dc-80138adde3f2",
},
),
)
Expect(integration.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/aliased-handlers.IntegrationHandlerAlias",
),
)
})
})
83 changes: 83 additions & 0 deletions static/app_handler_adaptor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package static_test

import (
"github.com/dogmatiq/configkit"
. "github.com/dogmatiq/configkit/static"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("partial handler implementations registered via adaptor functions", func() {
It("builds the configuration from the partial implementation", func() {
apps := FromDir("testdata/apps/handler-via-adaptor")
Expect(apps).To(HaveLen(1))
Expect(apps[0].Handlers().Aggregates()).To(HaveLen(1))
Expect(apps[0].Handlers().Processes()).To(HaveLen(1))
Expect(apps[0].Handlers().Projections()).To(HaveLen(1))
Expect(apps[0].Handlers().Integrations()).To(HaveLen(1))

aggregate := apps[0].Handlers().Aggregates()[0]
Expect(aggregate.Identity()).To(
Equal(
configkit.Identity{
Name: "<aggregate>",
Key: "ef16c9d1-d7b6-4c99-a0e7-a59218e544fc",
},
),
)
Expect(aggregate.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/handler-via-adaptor.AggregateHandler",
),
)
Expect(aggregate.HandlerType()).To(Equal(configkit.AggregateHandlerType))

process := apps[0].Handlers().Processes()[0]
Expect(process.Identity()).To(
Equal(
configkit.Identity{
Name: "<process>",
Key: "5e839b73-170b-42c0-bf41-8feee4b5a583",
},
),
)
Expect(process.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/handler-via-adaptor.ProcessHandler",
),
)
Expect(process.HandlerType()).To(Equal(configkit.ProcessHandlerType))

projection := apps[0].Handlers().Projections()[0]
Expect(projection.Identity()).To(
Equal(
configkit.Identity{
Name: "<projection>",
Key: "823e61d3-ace1-469d-b0a6-778e84c0a508",
},
),
)
Expect(projection.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/handler-via-adaptor.ProjectionHandler",
),
)
Expect(projection.HandlerType()).To(Equal(configkit.ProjectionHandlerType))

integration := apps[0].Handlers().Integrations()[0]
Expect(integration.Identity()).To(
Equal(
configkit.Identity{
Name: "<integration>",
Key: "099b5b8d-9e04-422f-bcc3-bb0d451158c7",
},
),
)
Expect(integration.TypeName()).To(
Equal(
"github.com/dogmatiq/configkit/static/testdata/apps/handler-via-adaptor.IntegrationHandler",
),
)
Expect(integration.HandlerType()).To(Equal(configkit.IntegrationHandlerType))
})
})
Loading

0 comments on commit 27b217c

Please sign in to comment.