Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding unit tests to workflowHandler_test.go #5500

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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