Skip to content

Commit

Permalink
Error for unused operation
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanos committed Oct 2, 2024
1 parent 772bc83 commit c596400
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ type (
// workflow completion callback. Only settable by the SDK - e.g. [temporalnexus.workflowRunOperation].
callbacks []*commonpb.Callback
// links. Only settable by the SDK - e.g. [temporalnexus.workflowRunOperation].
links []*commonpb.Link
links []*commonpb.Link
}

// WithStartWorkflowOperation is a type of operation that can be executed as part of a workflow start.
Expand Down Expand Up @@ -1082,6 +1082,9 @@ func (op *UpdateWithStartWorkflowOperation) Get(ctx context.Context) (WorkflowUp
case <-op.doneCh:
return op.handle, op.err
case <-ctx.Done():
if !op.executed.Load() {
return nil, fmt.Errorf("operation was not executed: %v", ctx.Err())
}
return nil, ctx.Err()
}
}
Expand Down
28 changes: 28 additions & 0 deletions internal/internal_workflow_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,34 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Retry() {
s.NoError(err)
}

func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_OperationNotExecuted() {
s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).
Return(&workflowservice.StartWorkflowExecutionResponse{
RunId: runID,
}, nil)

updOp := NewUpdateWithStartWorkflowOperation(
UpdateWorkflowOptions{
UpdateName: "update",
WaitForStage: WorkflowUpdateStageCompleted,
})

ctxWithTimeout, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

_, err := s.workflowClient.ExecuteWorkflow(

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest, oldstable)

this value of err is never used (SA4006)

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest, stable)

this value of err is never used (SA4006)

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (macos-intel, oldstable)

this value of err is never used (SA4006)

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (macos-intel, stable)

this value of err is never used (SA4006)

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (macos-arm, oldstable)

this value of err is never used (SA4006)

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (macos-arm, stable)

this value of err is never used (SA4006)

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (windows-latest, oldstable)

this value of err is never used (SA4006)

Check failure on line 1045 in internal/internal_workflow_client_test.go

View workflow job for this annotation

GitHub Actions / build-and-test (windows-latest, stable)

this value of err is never used (SA4006)
ctxWithTimeout,
StartWorkflowOptions{
ID: workflowID,
TaskQueue: taskqueue,
// WithStartOperation is not specified!
}, workflowType,
)

_, err = updOp.Get(ctxWithTimeout)
require.EqualError(s.T(), err, "operation was not executed: context deadline exceeded")
}

func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Abort() {
tests := []struct {
name string
Expand Down

0 comments on commit c596400

Please sign in to comment.