Skip to content

Commit

Permalink
Adding unit tests to workflowHandler_test.go (#5500)
Browse files Browse the repository at this point in the history
* Adding unit tests to workflowHandler_test.go

* Update workflowHandler_test.go
  • Loading branch information
sankari165 authored Dec 20, 2023
1 parent 69675a8 commit ec9b22e
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions service/frontend/workflowHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,50 @@ func (s *workflowHandlerSuite) TestRegisterDomain_Success_NotEnabled() {
s.NoError(err)
}

func (s *workflowHandlerSuite) TestListDomains_Success() {
domain := persistenceGetDomainResponse(
&domain.ArchivalState{},
&domain.ArchivalState{},
)
listDomainResp := &persistence.ListDomainsResponse{
Domains: []*persistence.GetDomainResponse{
domain,
domain,
},
}
s.mockMetadataMgr.
On("ListDomains", mock.Anything, mock.Anything).
Return(listDomainResp, nil)
wh := s.getWorkflowHandler(s.newConfig(dc.NewInMemoryClient()))

result, err := wh.ListDomains(context.Background(), &types.ListDomainsRequest{})
s.NoError(err)
s.Equal(2, len(result.GetDomains()))
}

func (s *workflowHandlerSuite) TestListDomains_RequestNotSet() {
wh := s.getWorkflowHandler(s.newConfig(dc.NewInMemoryClient()))

result, err := wh.ListDomains(context.Background(), nil /* list request is not set */)
s.Error(err)
s.Equal(errRequestNotSet, err)
s.Nil(result)
}

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)
}

func (s *workflowHandlerSuite) TestDescribeDomain_Success_ArchivalDisabled() {
getDomainResp := persistenceGetDomainResponse(
&domain.ArchivalState{Status: types.ArchivalStatusDisabled, URI: ""},
Expand Down

0 comments on commit ec9b22e

Please sign in to comment.