Skip to content

Commit

Permalink
Fix GetWorkflowResult to return nil instead of ErrNoData (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
vancexu authored Jul 15, 2020
1 parent e939630 commit 0357ffa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/workflow_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ func (t *TestWorkflowEnvironment) GetWorkflowResult(valuePtr interface{}) error
if !t.impl.isTestCompleted {
panic("workflow is not completed")
}
if t.impl.testError != nil || t.impl.testResult == nil || valuePtr == nil {
if t.impl.testError != nil || t.impl.testResult == nil || t.impl.testResult.HasValue() == false || valuePtr == nil {
return t.impl.testError
}
return t.impl.testResult.Get(valuePtr)
Expand Down
20 changes: 20 additions & 0 deletions internal/workflow_testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,23 @@ func TestNoExplicitRegistrationRequired(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "Hello World!", result)
}

func TestWorkflowReturnNil(t *testing.T) {
testSuite := &WorkflowTestSuite{}
env := testSuite.NewTestWorkflowEnvironment()

var isExecuted bool
testWF := func(ctx Context) error {
isExecuted = true
return nil
}
env.ExecuteWorkflow(testWF)

require.True(t, env.IsWorkflowCompleted())
require.NoError(t, env.GetWorkflowError())
require.True(t, isExecuted)

var r struct{}
err := env.GetWorkflowResult(&r)
require.NoError(t, err)
}

0 comments on commit 0357ffa

Please sign in to comment.