I’m attempting to write a unit test to confirm a workflow is started.
Signature of function under test:
func ViewSummaryWorkflow(context workflow.Context, personId int64) (Summary, error)
func (testSuite *ViewSummaryTestSuite) TestViewSummaryInvokesWorkflow() {
personId := int64(123)
expected := workflows.Summary{PersonId: personId, Name: "Sam Doe"}
testSuite.env.RegisterWorkflow(workflows.ViewSummaryWorkflow)
testSuite.env.OnWorkflow(workflows.ViewSummaryWorkflow, mock.Anything, personId).Return(expected, nil)
temporal, _ := client.NewClient(client.Options{})
actual := workflows.ViewSummary(temporal, strconv.FormatInt(personId, 10))
testSuite.Equal(expected, actual)
}
type ViewSummaryTestSuite struct {
suite.Suite
testsuite.WorkflowTestSuite
env *testsuite.TestWorkflowEnvironment
}
func TestViewSummaryTestSuite(t *testing.T) {
suite.Run(t, new(ViewSummaryTestSuite))
}
func (testSuite *ViewSummaryTestSuite) SetupTest() {
testSuite.env = testSuite.NewTestWorkflowEnvironment()
}
func (testSuite *ViewSummaryTestSuite) AfterTest(suiteName, testName string) {
testSuite.env.AssertExpectations(testSuite.T())
}
AssertExpectations failed with:
FAIL: 0 out of 1 expectation(s) were met.
The code you are testing needs to make 1 more call(s).
I’ve verified that the expected value is returned. What am I missing?
Thank you in advanced.