Skip to content

Bug: inferred func names are ambiguous, cause misbehavior due to alias #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions internal/internal_workflow_testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1792,3 +1792,40 @@ func (s *WorkflowTestSuiteUnitTest) Test_ContextMisuse() {
s.Error(env.GetWorkflowError())
s.Contains(env.GetWorkflowError().Error(), "block on coroutine which is already blocked")
}

func (s *WorkflowTestSuiteUnitTest) Test_AmbiguousRegistration() {
workflowFn := func(ctx Context) error {
ctx = WithActivityOptions(ctx, ActivityOptions{
ScheduleToStartTimeout: time.Minute,
StartToCloseTimeout: time.Minute,
})
return ExecuteActivity(ctx, f1).Get(ctx, nil)
}
env := s.NewTestWorkflowEnvironment()
RegisterWorkflow(workflowFn)

env.OnActivity("f1").Return(errors.New("f1 called"))
env.OnActivity("f2").Return(errors.New("incorrect behavior, f2 called"))

env.ExecuteWorkflow(workflowFn)

s.True(env.IsWorkflowCompleted())
s.Error(env.GetWorkflowError())

// note that this will fail - f2 was called.
// if you swap f1 and f2 registers in the init below, it'll pass, because the second write wins.
s.Contains(env.GetWorkflowError().Error(), "f1 called")
}

func init() {
f1 = reg("f1")
f2 = reg("f2")
}

var f1, f2 func() error

func reg(name string) func() error {
f := func() error { return nil }
RegisterActivityWithOptions(f, RegisterActivityOptions{name})
return f
}