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

Added handler tests and transmissionHandler mock to generate cases #5884

Merged
merged 6 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
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
30 changes: 30 additions & 0 deletions common/domain/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,36 @@ func TestRegisterDomain(t *testing.T) {
wantErr: true,
expectedErr: &types.BadRequestError{},
},
{
name: "invalid history archival configuration",
request: &types.RegisterDomainRequest{
Name: "test-domain-invalid-archival-config",
HistoryArchivalStatus: types.ArchivalStatusEnabled.Ptr(),
HistoryArchivalURI: "invalid-uri",
IsGlobalDomain: true,
},
isPrimaryCluster: true,
mockSetup: func(mockDomainMgr *persistence.MockDomainManager, request *types.RegisterDomainRequest) {
mockDomainMgr.EXPECT().GetDomain(gomock.Any(), &persistence.GetDomainRequest{Name: request.Name}).Return(nil, &types.EntityNotExistsError{})
},
wantErr: true,
expectedErr: errInvalidArchivalConfig,
},
{
name: "error during domain creation",
request: &types.RegisterDomainRequest{
Name: "domain-creation-error",
WorkflowExecutionRetentionPeriodInDays: 2,
IsGlobalDomain: false,
},
isPrimaryCluster: true,
mockSetup: func(mockDomainMgr *persistence.MockDomainManager, request *types.RegisterDomainRequest) {
mockDomainMgr.EXPECT().GetDomain(gomock.Any(), &persistence.GetDomainRequest{Name: request.Name}).Return(nil, &types.EntityNotExistsError{})

mockDomainMgr.EXPECT().CreateDomain(gomock.Any(), gomock.Any()).Return(nil, errors.New("creation failed"))
},
wantErr: true,
},
}

for _, tc := range tests {
Expand Down
2 changes: 2 additions & 0 deletions common/domain/transmissionTaskHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination transmissionTaskHandler_mock.go

package domain

import (
Expand Down
74 changes: 74 additions & 0 deletions common/domain/transmissionTaskHandler_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading