I am having a hard time in writing tests for my workflows.
I have a scenario where on failure of any activity in my workflow, I call a handleError function which executes an UpdateDB activity that updates the DB which a value indicating failure.
Now I am trying to write tests for this using go sdk. How can I test that on activity error -
- handleError method was called
- UpdateDB activity in handleError was executed
- And the right value was sent as input to UpdateDB (because the same activity is executed in other usecases as well with different values)
You can use
OnActivity of the test environment to mock the
UpdateDB activity and check its inputs (and that it was called, which lets you know
handleError therefore was called).
Thanks for replying Chad!
Can you please give an example on how to check the inputs of the mocked activity? Will the inputs not be what I send in OnActivity?
env.OnActivity(activity.UpdateDB, mock.Anything, mock.Anything).Return(“”, nil)
This is essentially the same as mock’s Call.On, so you can pass the same things for parameters there. Or you can just let
mock.Anything pass through and validate in the callback. How to use a callback is shown in the docs for