I can’t figure out a way to test side effects. Is there an idiomatic way to do this?
I tried executing the workflow twice but get an error saying I have to use a new test environment and I can’t seem to be able to set the reuse policy since the options are declared in an internal package.
Are you trying to test that SideEffect will not get re-executed on internal worker history replay?
If so, I’m not sure you need to test Temporal internal features, the SDK has extensive tests for this.
One thing maybe you could do is get the workflow history (json) of an execution that used workflow.SideEffect (so has the MarkerRecorded event in history with its recorded result) and then debug it via WorkflowReplayer) to see no new uuid is generated (but already recorded result is used).
Just to add, you should not put any command-generating commands in SideEffect, for example workflow.ExecuteActivity/ChildWorkflow, create timers, upsert search attributes etc.
Thanks @tihomir, I understand that testing the SDK’s internal features may not be necessary. However, as someone who is used to the testing practices in the Swift Composable Architecture (TCA), I find it valuable to document and ensure that the system behaves as expected. Specifically, in TCA’s TestStore, I am accustomed to having to exhaustively prove how the entire system of a feature evolves over time. In this case, I was trying to write a test that would ensure that the workflow.SideEffect function is not re-executed. And as you mentioned, I could use the workflow history to confirm that the recorded result is used.
On the subject of testing, I have also been unable to figure out how to test for heartbeat timeouts. I recall watching videos that mentioned the ability to advance time, but I have been unable to find any documentation on how to do this. The Queries section of the legacy documentation includes an example for a delayed callback, but not much else.
The current documentation for Go is unavailable and maybe should point to the godocs:
The godocs also do not explain how to advance time by a certain amount. This is in contrast to libraries like swift-clocks that allows you to test time-based functionality.
Despite this confusion, I want to express my admiration for the Temporal project. I’ve spent the past week watching all of your YouTube videos and reading and rereading all the documentation I could find. I’ve taken notes on everything that I found confusing as a new user and I would be happy to share and contribute to the project. I believe in the potential of Temporal and I’m excited to continue learning more about it.