generated from dogmatiq/template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use generic message stubs in static analysis tests.
- Loading branch information
Showing
69 changed files
with
586 additions
and
2,327 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
), | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}) | ||
}) |
Oops, something went wrong.