From aa2dafb0ab2cf5c6ab227020ac66346e0152449c Mon Sep 17 00:00:00 2001 From: James Harris Date: Tue, 26 Mar 2024 07:37:26 +1000 Subject: [PATCH] Add engine test. --- engine/engine_test.go | 24 ++++++++++++++++++++++++ go.mod | 1 + go.sum | 2 ++ internal/fixtures/protobuf.pb.go | 6 +++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/engine/engine_test.go b/engine/engine_test.go index 7503f3e5..520f666c 100644 --- a/engine/engine_test.go +++ b/engine/engine_test.go @@ -3,6 +3,7 @@ package engine_test import ( "context" "errors" + "testing" "time" "github.com/dogmatiq/configkit" @@ -10,6 +11,8 @@ import ( "github.com/dogmatiq/configkit/message" "github.com/dogmatiq/dogma" . "github.com/dogmatiq/dogma/fixtures" + "github.com/dogmatiq/enginekit/enginetest" + "github.com/dogmatiq/testkit/engine" . "github.com/dogmatiq/testkit/engine" "github.com/dogmatiq/testkit/envelope" "github.com/dogmatiq/testkit/fact" @@ -17,6 +20,27 @@ import ( . "github.com/onsi/gomega" ) +func TestEngine(t *testing.T) { + enginetest.RunTests( + t, + func(p enginetest.SetupParams) enginetest.SetupResult { + e, err := New(configkit.FromApplication(p.App)) + if err != nil { + t.Fatal(err) + } + + return enginetest.SetupResult{ + RunEngine: func(ctx context.Context) error { + return Run(ctx, e, 0) + }, + Executor: &engine.CommandExecutor{ + Engine: e, + }, + } + }, + ) +} + var _ = g.Describe("type Engine", func() { var ( aggregate *AggregateMessageHandler diff --git a/go.mod b/go.mod index 1e79a96d..a75f0c65 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/dogmatiq/cosyne v0.2.0 github.com/dogmatiq/dapper v0.5.1 github.com/dogmatiq/dogma v0.12.1 + github.com/dogmatiq/enginekit v0.0.0-20240305232210-250991e0d96a github.com/dogmatiq/iago v0.4.0 github.com/dogmatiq/linger v1.1.0 github.com/onsi/ginkgo/v2 v2.17.0 diff --git a/go.sum b/go.sum index b0ee9995..618074f1 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/dogmatiq/dapper v0.5.1 h1:ukchNhVD9XUPsdEebJCmCsi1LaTDyouz3HrwoiYUSSU github.com/dogmatiq/dapper v0.5.1/go.mod h1:GkboktespYmpKgOG70ylT1gmD0LE12NL1YtDnLd1j/E= github.com/dogmatiq/dogma v0.12.1 h1:mWIzmi3jio9ZnHJeJKNS5D19O2S4x4SLSxGXXn3IQiQ= github.com/dogmatiq/dogma v0.12.1/go.mod h1:op4IjAGC593ONvvUPhh2xNyk/3Ezv9HkCPRlzdbkX9Y= +github.com/dogmatiq/enginekit v0.0.0-20240305232210-250991e0d96a h1:CZZrqIf63a4BQHwkZHQtmfg4GxogIQ4KsJnVHDjBHuk= +github.com/dogmatiq/enginekit v0.0.0-20240305232210-250991e0d96a/go.mod h1:MrYjDhp8dz6/+dAGlR5T3/1dVX5h2AtdlKu7DIA5sTg= github.com/dogmatiq/iago v0.4.0 h1:57nZqVT34IZxtCZEW/RFif7DNUEjMXgevfr/Mmd0N8I= github.com/dogmatiq/iago v0.4.0/go.mod h1:fishMWBtzYcjgis6d873VTv9kFm/wHYLOzOyO9ECBDc= github.com/dogmatiq/jumble v0.1.0 h1:Cb3ExfxY+AoUP4G9/sOwoOdYX8o+kOLK8+dhXAry+QA= diff --git a/internal/fixtures/protobuf.pb.go b/internal/fixtures/protobuf.pb.go index e13807ad..ff19522e 100644 --- a/internal/fixtures/protobuf.pb.go +++ b/internal/fixtures/protobuf.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.33.0 // protoc v4.23.4 // source: github.com/dogmatiq/testkit/internal/fixtures/protobuf.proto @@ -98,7 +98,7 @@ func file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_rawDescGZ } var file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_goTypes = []any{ +var file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_goTypes = []interface{}{ (*ProtoMessage)(nil), // 0: dogmatiq.testkit.fixtures.ProtoMessage } var file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_depIdxs = []int32{ @@ -115,7 +115,7 @@ func file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_msgTypes[0].Exporter = func(v any, i int) any { + file_github_com_dogmatiq_testkit_internal_fixtures_protobuf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ProtoMessage); i { case 0: return &v.state