Skip to content

Commit 0357ffa

Browse files
authored
Fix GetWorkflowResult to return nil instead of ErrNoData (#1000)
1 parent e939630 commit 0357ffa

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

internal/workflow_testsuite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func (t *TestWorkflowEnvironment) GetWorkflowResult(valuePtr interface{}) error
584584
if !t.impl.isTestCompleted {
585585
panic("workflow is not completed")
586586
}
587-
if t.impl.testError != nil || t.impl.testResult == nil || valuePtr == nil {
587+
if t.impl.testError != nil || t.impl.testResult == nil || t.impl.testResult.HasValue() == false || valuePtr == nil {
588588
return t.impl.testError
589589
}
590590
return t.impl.testResult.Get(valuePtr)

internal/workflow_testsuite_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,23 @@ func TestNoExplicitRegistrationRequired(t *testing.T) {
112112
require.NoError(t, err)
113113
require.Equal(t, "Hello World!", result)
114114
}
115+
116+
func TestWorkflowReturnNil(t *testing.T) {
117+
testSuite := &WorkflowTestSuite{}
118+
env := testSuite.NewTestWorkflowEnvironment()
119+
120+
var isExecuted bool
121+
testWF := func(ctx Context) error {
122+
isExecuted = true
123+
return nil
124+
}
125+
env.ExecuteWorkflow(testWF)
126+
127+
require.True(t, env.IsWorkflowCompleted())
128+
require.NoError(t, env.GetWorkflowError())
129+
require.True(t, isExecuted)
130+
131+
var r struct{}
132+
err := env.GetWorkflowResult(&r)
133+
require.NoError(t, err)
134+
}

0 commit comments

Comments
 (0)