I am writing a unit test for cadence activity function which is using an UUID to retrieve a contact from the contact service. I wonder what context should I pass into cadence activity.
activity.Register(GetContactActivityFunc)
func GetContactActivityFunc(ctx context.Context, input ContactBbInput) (ContactBbOutput, error) {
...
}
This is testing function.
func TestGetContactActivityFunc(t *testing.T) {
mockCSInterface := &mocks.Interface{}
csClient := outbound.NewContactServiceClient(mockCSInterface)
ctx := context.Background()
ctx = context.WithValue(ctx, outbound.ContactServiceClientKey, csClient)
contactUUID := contact.UUID("917801ab-36ff-4eea-8352-d6eafedb5106")
bbInput := ContactBbInput{
ContactID: &contactUUID,
}
bbOut, err := GetContactActivityFunc(ctx, bbInput)
assert.NoError(t, err)
assert.NotNil(t, bbOut.ContactObj)
}
The error message I got:
--- FAIL: TestGetContactActivityFunc (0.00s)
panic: getActivityEnv: Not an activity context [recovered]
panic: getActivityEnv: Not an activity context