@@ -1113,30 +1113,80 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Abort() {
1113
1113
}
1114
1114
}
1115
1115
1116
- func (s * workflowRunSuite ) TestExecuteWorkflowWithUpdate_NonMultiOperationError () {
1117
- s .workflowServiceClient .EXPECT ().
1118
- ExecuteMultiOperation (gomock .Any (), gomock .Any (), gomock .Any ()).
1119
- Return (nil , serviceerror .NewInternal ("internal error" )).Times (1 )
1116
+ func (s * workflowRunSuite ) TestExecuteWorkflowWithUpdate_Errors () {
1117
+ tests := []struct {
1118
+ name string
1119
+ returnedErr error
1120
+ expectedErr string
1121
+ }{
1122
+ {
1123
+ name : "NonMultiOperationError" ,
1124
+ returnedErr : serviceerror .NewInternal ("internal error" ),
1125
+ expectedErr : "internal error" ,
1126
+ },
1127
+ {
1128
+ name : "CountMismatch" ,
1129
+ returnedErr : serviceerror .NewMultiOperationExecution ("Error" , []error {}),
1130
+ expectedErr : "invalid server response: 0 instead of 2 operation errors" ,
1131
+ },
1132
+ {
1133
+ name : "NilErrors" ,
1134
+ returnedErr : serviceerror .NewMultiOperationExecution ("MultiOperation failed" , []error {
1135
+ nil , nil ,
1136
+ }),
1137
+ expectedErr : "MultiOperation failed" ,
1138
+ },
1139
+ {
1140
+ name : "StartOperationError" ,
1141
+ returnedErr : serviceerror .NewMultiOperationExecution ("MultiOperation failed" , []error {
1142
+ serviceerror .NewInvalidArgument ("invalid Start" ),
1143
+ serviceerror .NewMultiOperationAborted ("aborted Update" ),
1144
+ }),
1145
+ expectedErr : "failed workflow start: invalid Start" ,
1146
+ },
1147
+ {
1148
+ name : "UpdateOperationError_AbortedStart" ,
1149
+ returnedErr : serviceerror .NewMultiOperationExecution ("MultiOperation failed" , []error {
1150
+ serviceerror .NewMultiOperationAborted ("aborted Start" ),
1151
+ serviceerror .NewInvalidArgument ("invalid Update" ),
1152
+ }),
1153
+ expectedErr : "failed workflow update: invalid Update" ,
1154
+ },
1155
+ {
1156
+ name : "UpdateOperationError_SuccessfulStart" ,
1157
+ returnedErr : serviceerror .NewMultiOperationExecution ("MultiOperation failed" , []error {
1158
+ nil , // ie successful start
1159
+ serviceerror .NewInvalidArgument ("bad Update" ),
1160
+ }),
1161
+ expectedErr : "failed workflow update: bad Update" ,
1162
+ },
1163
+ }
1120
1164
1121
- startOp := s .workflowClient .NewWithStartWorkflowOperation (
1122
- StartWorkflowOptions {
1123
- ID : workflowID ,
1124
- WorkflowIDConflictPolicy : enumspb .WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1125
- TaskQueue : taskqueue ,
1126
- }, workflowType ,
1127
- )
1165
+ for _ , tt := range tests {
1166
+ s .Run (tt .name , func () {
1167
+ s .workflowServiceClient .EXPECT ().
1168
+ ExecuteMultiOperation (gomock .Any (), gomock .Any (), gomock .Any ()).
1169
+ Return (nil , tt .returnedErr ).Times (1 )
1128
1170
1129
- _ , err := s .workflowClient .UpdateWithStartWorkflow (
1130
- context .Background (),
1131
- UpdateWithStartWorkflowOptions {
1132
- UpdateOptions : UpdateWorkflowOptions {
1133
- UpdateName : "update" ,
1134
- WaitForStage : WorkflowUpdateStageCompleted ,
1135
- },
1136
- StartWorkflowOperation : startOp ,
1137
- },
1138
- )
1139
- s .ErrorContains (err , "internal error" )
1171
+ _ , err := s .workflowClient .UpdateWithStartWorkflow (
1172
+ context .Background (),
1173
+ UpdateWithStartWorkflowOptions {
1174
+ UpdateOptions : UpdateWorkflowOptions {
1175
+ UpdateName : "update" ,
1176
+ WaitForStage : WorkflowUpdateStageCompleted ,
1177
+ },
1178
+ StartWorkflowOperation : s .workflowClient .NewWithStartWorkflowOperation (
1179
+ StartWorkflowOptions {
1180
+ ID : workflowID ,
1181
+ WorkflowIDConflictPolicy : enumspb .WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1182
+ TaskQueue : taskqueue ,
1183
+ }, workflowType ,
1184
+ ),
1185
+ },
1186
+ )
1187
+ s .EqualError (err , tt .expectedErr )
1188
+ })
1189
+ }
1140
1190
}
1141
1191
1142
1192
func (s * workflowRunSuite ) TestExecuteWorkflowWithUpdate_ServerResponseCountMismatch () {
@@ -1167,32 +1217,6 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerResponseCountMism
1167
1217
s .ErrorContains (err , "invalid server response: 0 instead of 2 operation results" )
1168
1218
}
1169
1219
1170
- func (s * workflowRunSuite ) TestExecuteWorkflowWithUpdate_ServerErrorResponseCountMismatch () {
1171
- s .workflowServiceClient .EXPECT ().
1172
- ExecuteMultiOperation (gomock .Any (), gomock .Any (), gomock .Any ()).
1173
- Return (nil , serviceerror .NewMultiOperationExecution ("Error" , []error {})).Times (1 )
1174
-
1175
- startOp := s .workflowClient .NewWithStartWorkflowOperation (
1176
- StartWorkflowOptions {
1177
- ID : workflowID ,
1178
- WorkflowIDConflictPolicy : enumspb .WORKFLOW_ID_CONFLICT_POLICY_FAIL ,
1179
- TaskQueue : taskqueue ,
1180
- }, workflowType ,
1181
- )
1182
-
1183
- _ , err := s .workflowClient .UpdateWithStartWorkflow (
1184
- context .Background (),
1185
- UpdateWithStartWorkflowOptions {
1186
- UpdateOptions : UpdateWorkflowOptions {
1187
- UpdateName : "update" ,
1188
- WaitForStage : WorkflowUpdateStageCompleted ,
1189
- },
1190
- StartWorkflowOperation : startOp ,
1191
- },
1192
- )
1193
- s .ErrorContains (err , "invalid server response: 0 instead of 2 operation errors" )
1194
- }
1195
-
1196
1220
func (s * workflowRunSuite ) TestExecuteWorkflowWithUpdate_ServerStartResponseTypeMismatch () {
1197
1221
s .workflowServiceClient .EXPECT ().
1198
1222
ExecuteMultiOperation (gomock .Any (), gomock .Any (), gomock .Any ()).
0 commit comments