diff --git a/service/frontend/workflowHandler_test.go b/service/frontend/workflowHandler_test.go index 96c8614329c..8ef8cf3fd68 100644 --- a/service/frontend/workflowHandler_test.go +++ b/service/frontend/workflowHandler_test.go @@ -585,6 +585,57 @@ func (s *workflowHandlerSuite) TestStartWorkflowExecution_IsolationGroupDrained( s.IsType(err, &types.BadRequestError{}) } +func (s *workflowHandlerSuite) TestRecordActivityTaskHeartbeat_Success() { + wh := s.getWorkflowHandler(s.newConfig(dc.NewInMemoryClient())) + taskToken := common.TaskToken{ + DomainID: s.testDomainID, + WorkflowID: testWorkflowID, + RunID: testRunID, + ActivityID: "1", + } + taskTokenBytes, err := wh.tokenSerializer.Serialize(&taskToken) + s.NoError(err) + req := &types.RecordActivityTaskHeartbeatRequest{ + TaskToken: taskTokenBytes, + Details: nil, + Identity: "", + } + resp := &types.RecordActivityTaskHeartbeatResponse{CancelRequested: false} + + s.mockDomainCache.EXPECT().GetDomainName(s.testDomainID).Return(s.testDomain, nil) + s.mockHistoryClient.EXPECT().RecordActivityTaskHeartbeat(gomock.Any(), + &types.HistoryRecordActivityTaskHeartbeatRequest{ + DomainUUID: s.testDomainID, + HeartbeatRequest: req, + }).Return(resp, nil) + + result, err := wh.RecordActivityTaskHeartbeat(context.Background(), req) + s.NoError(err) + s.Equal(resp, result) +} + +func (s *workflowHandlerSuite) TestRecordActivityTaskHeartbeat_RequestNotSet() { + wh := s.getWorkflowHandler(s.newConfig(dc.NewInMemoryClient())) + result, err := wh.RecordActivityTaskHeartbeat(context.Background(), nil /*request is not set*/) + + s.Error(err) + s.Equal(errRequestNotSet, err) + s.Nil(result) +} + +func (s *workflowHandlerSuite) TestRecordActivityTaskHeartbeat_TaskTokenNotSet() { + wh := s.getWorkflowHandler(s.newConfig(dc.NewInMemoryClient())) + result, err := wh.RecordActivityTaskHeartbeat(context.Background(), &types.RecordActivityTaskHeartbeatRequest{ + TaskToken: nil, //task token is not set + Details: nil, + Identity: "", + }) + + s.Error(err) + s.Equal(errTaskTokenNotSet, err) + s.Nil(result) +} + func (s *workflowHandlerSuite) TestRegisterDomain_Failure_MissingDomainDataKey() { dynamicClient := dc.NewInMemoryClient() err := dynamicClient.UpdateValue(dc.RequiredDomainDataKeys, map[string]interface{}{"Tier": true}) @@ -720,6 +771,7 @@ func (s *workflowHandlerSuite) TestListDomains_Success() { result, err := wh.ListDomains(context.Background(), &types.ListDomainsRequest{}) s.NoError(err) + s.Equal(2, len(result.GetDomains())) } @@ -736,12 +788,13 @@ func (s *workflowHandlerSuite) TestHealth_StatusOK() { wh := s.getWorkflowHandler(s.newConfig(dc.NewInMemoryClient())) // workflow handler gets initial health status as HealthStatusWarmingUp result, err := wh.Health(context.Background()) // Health check looks for HealthStatusOK + s.NoError(err) s.False(result.Ok) wh.UpdateHealthStatus(HealthStatusOK) - result, err = wh.Health(context.Background()) + s.NoError(err) s.True(result.Ok) }