Skip to content

Commit 24258b1

Browse files
committed
add test and missing functions
1 parent 5608f3f commit 24258b1

File tree

8 files changed

+70
-0
lines changed

8 files changed

+70
-0
lines changed

internal/common/auth/service_wrapper_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ func (s *serviceWrapperSuite) TestDescribeWorkflowExecutionInvalidToken() {
140140
s.EqualError(err, "error")
141141
}
142142

143+
func (s *serviceWrapperSuite) TestDiagnoseWorkflowExecutionValidToken() {
144+
s.Service.EXPECT().DiagnoseWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Times(1)
145+
sw := NewWorkflowServiceWrapper(s.Service, s.AuthProvider)
146+
ctx, _ := thrift.NewContext(time.Minute)
147+
_, err := sw.DiagnoseWorkflowExecution(ctx, &shared.DiagnoseWorkflowExecutionRequest{})
148+
s.NoError(err)
149+
}
150+
151+
func (s *serviceWrapperSuite) TestDiagnoseWorkflowExecutionInvalidToken() {
152+
s.AuthProvider = newJWTAuthIncorrect()
153+
sw := NewWorkflowServiceWrapper(s.Service, s.AuthProvider)
154+
ctx, _ := thrift.NewContext(time.Minute)
155+
_, err := sw.DiagnoseWorkflowExecution(ctx, &shared.DiagnoseWorkflowExecutionRequest{})
156+
s.EqualError(err, "error")
157+
}
158+
143159
func (s *serviceWrapperSuite) TestGetWorkflowExecutionHistoryValidToken() {
144160
s.Service.EXPECT().GetWorkflowExecutionHistory(gomock.Any(), gomock.Any(), gomock.Any()).Times(1)
145161
sw := NewWorkflowServiceWrapper(s.Service, s.AuthProvider)

internal/common/isolationgroup/service_wrapper_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ func TestAPICalls(t *testing.T) {
8686
},
8787
expectedResponse: &shared.DescribeWorkflowExecutionResponse{},
8888
},
89+
"DiagnoseWorkflowExecution": {
90+
action: func(ctx context.Context, sw workflowserviceclient.Interface) (interface{}, error) {
91+
return sw.DiagnoseWorkflowExecution(ctx, &shared.DiagnoseWorkflowExecutionRequest{})
92+
},
93+
affordance: func(m *workflowservicetest.MockClient) {
94+
m.EXPECT().DiagnoseWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Times(1).Return(&shared.DiagnoseWorkflowExecutionResponse{}, nil)
95+
},
96+
expectedResponse: &shared.DiagnoseWorkflowExecutionResponse{},
97+
},
8998
"ListOpenWorkflowExecutions": {
9099
action: func(ctx context.Context, sw workflowserviceclient.Interface) (interface{}, error) {
91100
return sw.ListOpenWorkflowExecutions(ctx, &shared.ListOpenWorkflowExecutionsRequest{})

internal/compatibility/adapter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ func (a workflowAPIthriftAdapter) DescribeWorkflowExecution(ctx context.Context,
333333
response, err := a.service.DescribeWorkflowExecution(ctx, thrift.DescribeWorkflowExecutionRequest(request), opts...)
334334
return proto.DescribeWorkflowExecutionResponse(response), proto.Error(err)
335335
}
336+
func (a workflowAPIthriftAdapter) DiagnoseWorkflowExecution(ctx context.Context, request *apiv1.DiagnoseWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.DiagnoseWorkflowExecutionResponse, error) {
337+
response, err := a.service.DiagnoseWorkflowExecution(ctx, thrift.DiagnoseWorkflowExecutionRequest(request), opts...)
338+
return proto.DiagnoseWorkflowExecutionResponse(response), proto.Error(err)
339+
}
336340
func (a workflowAPIthriftAdapter) QueryWorkflow(ctx context.Context, request *apiv1.QueryWorkflowRequest, opts ...yarpc.CallOption) (*apiv1.QueryWorkflowResponse, error) {
337341
response, err := a.service.QueryWorkflow(ctx, thrift.QueryWorkflowRequest(request), opts...)
338342
return proto.QueryWorkflowResponse(response), proto.Error(err)

internal/compatibility/api_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ func TestDescribeWorkflowExecutionResponse(t *testing.T) {
217217
assert.Equal(t, item, proto.DescribeWorkflowExecutionResponse(thrift.DescribeWorkflowExecutionResponse(item)))
218218
}
219219
}
220+
func TestDiagnoseWorkflowExecutionRequest(t *testing.T) {
221+
for _, item := range []*apiv1.DiagnoseWorkflowExecutionRequest{nil, {}, &testdata.DiagnoseWorkflowExecutionRequest} {
222+
assert.Equal(t, item, proto.DiagnoseWorkflowExecutionRequest(thrift.DiagnoseWorkflowExecutionRequest(item)))
223+
}
224+
}
225+
func TestDiagnoseWorkflowExecutionResponse(t *testing.T) {
226+
for _, item := range []*apiv1.DiagnoseWorkflowExecutionResponse{nil, {}, &testdata.DiagnoseWorkflowExecutionResponse} {
227+
assert.Equal(t, item, proto.DiagnoseWorkflowExecutionResponse(thrift.DiagnoseWorkflowExecutionResponse(item)))
228+
}
229+
}
220230
func TestExternalWorkflowExecutionCancelRequestedEventAttributes(t *testing.T) {
221231
for _, item := range []*apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes{nil, {}, &testdata.ExternalWorkflowExecutionCancelRequestedEventAttributes} {
222232
assert.Equal(t, item, proto.ExternalWorkflowExecutionCancelRequestedEventAttributes(thrift.ExternalWorkflowExecutionCancelRequestedEventAttributes(item)))

internal/compatibility/proto/request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func DiagnoseWorkflowExecutionRequest(t *shared.DiagnoseWorkflowExecutionRequest
8888
return &apiv1.DiagnoseWorkflowExecutionRequest{
8989
Domain: t.GetDomain(),
9090
WorkflowExecution: WorkflowExecution(t.GetWorkflowExecution()),
91+
Identity: t.GetIdentity(),
9192
}
9293
}
9394

internal/compatibility/proto/response.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ func DescribeWorkflowExecutionResponse(t *shared.DescribeWorkflowExecutionRespon
8989
}
9090
}
9191

92+
func DiagnoseWorkflowExecutionResponse(t *shared.DiagnoseWorkflowExecutionResponse) *apiv1.DiagnoseWorkflowExecutionResponse {
93+
if t == nil {
94+
return nil
95+
}
96+
return &apiv1.DiagnoseWorkflowExecutionResponse{
97+
Domain: t.GetDomain(),
98+
DiagnosticWorkflowExecution: WorkflowExecution(t.DiagnosticWorkflowExecution),
99+
}
100+
}
101+
92102
func GetClusterInfoResponse(t *shared.ClusterInfo) *apiv1.GetClusterInfoResponse {
93103
if t == nil {
94104
return nil

internal/compatibility/testdata/service.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,15 @@ var (
382382
PendingChildren: PendingChildExecutionInfoArray,
383383
PendingDecision: &PendingDecisionInfo,
384384
}
385+
DiagnoseWorkflowExecutionRequest = apiv1.DiagnoseWorkflowExecutionRequest{
386+
Domain: DomainName,
387+
WorkflowExecution: &WorkflowExecution,
388+
Identity: Identity,
389+
}
390+
DiagnoseWorkflowExecutionResponse = apiv1.DiagnoseWorkflowExecutionResponse{
391+
Domain: DomainName,
392+
DiagnosticWorkflowExecution: &WorkflowExecution,
393+
}
385394
QueryWorkflowRequest = apiv1.QueryWorkflowRequest{
386395
Domain: DomainName,
387396
WorkflowExecution: &WorkflowExecution,

internal/compatibility/thrift/request.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ func DescribeWorkflowExecutionRequest(t *apiv1.DescribeWorkflowExecutionRequest)
8282
}
8383
}
8484

85+
func DiagnoseWorkflowExecutionRequest(t *apiv1.DiagnoseWorkflowExecutionRequest) *shared.DiagnoseWorkflowExecutionRequest {
86+
if t == nil {
87+
return nil
88+
}
89+
return &shared.DiagnoseWorkflowExecutionRequest{
90+
Domain: &t.Domain,
91+
WorkflowExecution: WorkflowExecution(t.WorkflowExecution),
92+
Identity: &t.Identity,
93+
}
94+
}
95+
8596
func GetWorkflowExecutionHistoryRequest(t *apiv1.GetWorkflowExecutionHistoryRequest) *shared.GetWorkflowExecutionHistoryRequest {
8697
if t == nil {
8798
return nil

0 commit comments

Comments
 (0)