Hi, how would I go about writing a unit test for a workflow similar to this?
The idea is I have workflow A that retrieves a workflow history of a different workflow B, and stores it to our data lake. Is there a way to run a test workflow B, then somehow retrieve its workflow history?
import (
"context"
"go.temporal.io/api/enums/v1"
"go.temporal.io/api/history/v1"
"go.temporal.io/sdk/client"
)
func GetWorkflowHistory(ctx context.Context, client client.Client, id, runID string) (*history.History, error) {
var hist history.History
iter := client.GetWorkflowHistory(ctx, id, runID, false, enums.HISTORY_EVENT_FILTER_TYPE_ALL_EVENT)
for iter.HasNext() {
event, err := iter.Next()
if err != nil {
return nil, err
}
hist.Events = append(hist.Events, event)
}
return &hist, nil
}
Source: Testing - Go SDK feature guide | Temporal Documentation