diff --git a/internal/workflow_testsuite.go b/internal/workflow_testsuite.go index 7630f2f43..0bcbf7d82 100644 --- a/internal/workflow_testsuite.go +++ b/internal/workflow_testsuite.go @@ -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) diff --git a/internal/workflow_testsuite_test.go b/internal/workflow_testsuite_test.go index 0a9549117..3a2a8cda3 100644 --- a/internal/workflow_testsuite_test.go +++ b/internal/workflow_testsuite_test.go @@ -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) +}