I have an HTTP handler that executes a workflow.
func () someHandler(w http.ResponseWriter, r *http.Request) {
workflowOptions := client.StartWorkflowOptions{
ID: id,
TaskQueue: c.OrderTasksQueueName,
}
we, err = c.TemporalClient.ExecuteWorkflow(context.Background(), workflowOptions, "MyWorkflow")
response := ""
responseErr := we.Get(context.Background(), &response)
if responseErr != nil {
c.Logger.Error("Cannot get workflow result")
}
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte("Unable to execute workflow"))
return
}
w.WriteHeader(http.StatusAccepted)
result := fmt.Sprintf("{WorkflowRunID: %s, OrderID: %s, Result: %s}", we.GetRunID(), we.GetID(),
response) _, _ = w.Write([]byte(result))
}```
1. How do I write unit tests for this handler. How can I get this workflow to execute without mocking.
2. Can I mock the workflow execution somehow and just test the handler logic?
Any help is appreciated.
Thanks