From b8222269031727f1486c1f66a0aa01434073cda8 Mon Sep 17 00:00:00 2001 From: Stefano Scafiti Date: Thu, 26 Jan 2023 11:10:00 +0100 Subject: [PATCH 1/3] Call invoker if Workflow is nil --- client/workflow/workflow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/workflow/workflow.go b/client/workflow/workflow.go index 4324448..a72bee2 100644 --- a/client/workflow/workflow.go +++ b/client/workflow/workflow.go @@ -229,7 +229,7 @@ func Interceptor(ctx context.Context, method string, req, reply interface{}, cc logger.Debugf("grpc client calling: %s%s %v", cc.Target(), method, dtmimp.MustMarshalString(req)) wf, _ := ctx.Value(wfMeta{}).(*Workflow) if wf == nil { - return nil + return invoker(ctx, method, req, reply, cc, opts...) } origin := func() error { From 64d935a740b394fc38fad67002c294e391aff7af Mon Sep 17 00:00:00 2001 From: Stefano Scafiti Date: Thu, 26 Jan 2023 14:02:10 +0100 Subject: [PATCH 2/3] Add workflow interceptor test --- test/workflow_interceptor_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/workflow_interceptor_test.go diff --git a/test/workflow_interceptor_test.go b/test/workflow_interceptor_test.go new file mode 100644 index 0000000..b501ec1 --- /dev/null +++ b/test/workflow_interceptor_test.go @@ -0,0 +1,19 @@ +package test + +import ( + "context" + "testing" + + "github.com/dtm-labs/dtm/client/workflow" + "github.com/stretchr/testify/assert" + "google.golang.org/grpc" +) + +func TestWorkflowInterceptorOutsideSaga(t *testing.T) { + called := false + workflow.Interceptor(context.TODO(), "method", nil, nil, nil, func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, opts ...grpc.CallOption) error { + called = true + return nil + }) + assert.True(t, called) +} From 5b2b4d5ce04d72992e1bf6f27e30cd36c54e6c5e Mon Sep 17 00:00:00 2001 From: Stefano Scafiti Date: Thu, 26 Jan 2023 14:43:19 +0100 Subject: [PATCH 3/3] Pass non empty grpc conn --- test/workflow_interceptor_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/workflow_interceptor_test.go b/test/workflow_interceptor_test.go index b501ec1..4c23112 100644 --- a/test/workflow_interceptor_test.go +++ b/test/workflow_interceptor_test.go @@ -11,7 +11,7 @@ import ( func TestWorkflowInterceptorOutsideSaga(t *testing.T) { called := false - workflow.Interceptor(context.TODO(), "method", nil, nil, nil, func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, opts ...grpc.CallOption) error { + workflow.Interceptor(context.TODO(), "method", nil, nil, &grpc.ClientConn{}, func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, opts ...grpc.CallOption) error { called = true return nil })