-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Issue
We recently were trying to create a unit test to reproduce an issue in live code where a workflow was completed while a pending future was inflight, expecting the error workflow completed, but there are still pending futures. However we found that we could not reproduce the error when the future was an activity. This prevents us from writing tests which validate that we don't leave pending futures on accident. This occurs regardless of if the activity is mocked or not.
Workflows version v1.3.0.
Reproduce:
Create this file:
package main
import (
"context"
"testing"
"time"
"github.com/cschleiden/go-workflows/tester"
wf "github.com/cschleiden/go-workflows/workflow"
"github.com/stretchr/testify/require"
)
func TestFoo(t *testing.T) {
wft := tester.NewWorkflowTester[any](WF)
// wft.OnActivity(Act, mock.Anything).Return(nil)
wft.Execute(t.Context())
require.True(t, wft.WorkflowFinished())
_, err := wft.WorkflowResult()
require.ErrorContains(t, err, "workflow completed, but there are still pending futures")
}
func WF(ctx wf.Context) error {
wf.ExecuteActivity[any](ctx, wf.DefaultActivityOptions, Act)
return nil
}
func Act(context.Context) error {
time.Sleep(10 * time.Second)
return nil
}Run command:
go test <file>
Expected result: the test is successful. Instead, the test reports no error returned from wft.WorkflowResult().
Thanks!
Copilot
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working