Skip to content

Commit

Permalink
Add test for side effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Jul 14, 2023
1 parent edb01db commit fe3293c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/internal_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,38 @@ func (s *WorkflowUnitTest) Test_WaitGroupWorkflowTest() {
s.Equal(n, total)
}

func (s *WorkflowUnitTest) Test_MutatingFunctionsInSideEffect() {
env := s.NewTestWorkflowEnvironment()

wf := func(ctx Context) error {
SideEffect(ctx, func(ctx Context) interface{} {
_ = Sleep(ctx, time.Minute)
return nil
})
return nil
}
env.RegisterWorkflow(wf)
env.ExecuteWorkflow(wf)
s.True(env.IsWorkflowCompleted())
s.Error(env.GetWorkflowError())
}

func (s *WorkflowUnitTest) Test_MutatingFunctionsInMutableSideEffect() {
env := s.NewTestWorkflowEnvironment()

wf := func(ctx Context) error {
MutableSideEffect(ctx, "test-side-effect", func(ctx Context) interface{} {
_ = Sleep(ctx, time.Minute)
return nil
}, func(a, b interface{}) bool { return false })
return nil
}
env.RegisterWorkflow(wf)
env.ExecuteWorkflow(wf)
s.True(env.IsWorkflowCompleted())
s.Error(env.GetWorkflowError())
}

func (s *WorkflowUnitTest) Test_MutatingFunctionsInQueries() {
env := s.NewTestWorkflowEnvironment()

Expand Down

0 comments on commit fe3293c

Please sign in to comment.