From 117f6e06aa6c0d3746298c60ed61c15b300ef552 Mon Sep 17 00:00:00 2001 From: Oriol Date: Fri, 22 Dec 2023 10:29:26 +0100 Subject: [PATCH] chore: Uses Mockery instead of manually created mocks in project unit tests (#1788) * use mockery to generate mocks * remove unnecessary maybe * change from testObject to svc * remove ProjectResponse in favor of specific structs --- .mockery.yaml | 2 + .../service/project/resource_project_test.go | 264 +++++------ .../testutil/mocksvc/group_project_service.go | 413 ++++++++++++++++++ 3 files changed, 518 insertions(+), 161 deletions(-) create mode 100644 internal/testutil/mocksvc/group_project_service.go diff --git a/.mockery.yaml b/.mockery.yaml index e8915da8d7..defc1945aa 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -8,6 +8,8 @@ mockname: "{{.InterfaceName}}" packages: ? github.com/mongodb/terraform-provider-mongodbatlas/internal/service/searchdeployment ? github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrest + ? github.com/mongodb/terraform-provider-mongodbatlas/internal/service/project : interfaces: DeploymentService: EarService: + GroupProjectService: diff --git a/internal/service/project/resource_project_test.go b/internal/service/project/resource_project_test.go index d8ed732ff7..85e3fa1f92 100644 --- a/internal/service/project/resource_project_test.go +++ b/internal/service/project/resource_project_test.go @@ -14,26 +14,14 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - // "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/project" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mocksvc" "github.com/stretchr/testify/mock" "go.mongodb.org/atlas-sdk/v20231115002/admin" ) var ( - successfulPaginatedTeamRole = ProjectResponse{ - ProjectTeamResp: &admin.PaginatedTeamRole{}, - Err: nil, - } - successfulDataFederationLimit = ProjectResponse{ - LimitsResponse: []admin.DataFederationLimit{}, - Err: nil, - } - successfulGroupSettingsResponse = ProjectResponse{ - GroupSettingsResponse: &admin.GroupSettings{}, - Err: nil, - } name = types.StringValue("sameName") diffName = types.StringValue("diffName") projectStateName = project.TfProjectRSModel{ @@ -46,48 +34,59 @@ var ( ) func TestGetProjectPropsFromAPI(t *testing.T) { + successfulTeamRoleResponse := TeamRoleResponse{ + TeamRole: &admin.PaginatedTeamRole{}, + Err: nil, + } + successfulLimitsResponse := LimitsResponse{ + Limits: []admin.DataFederationLimit{}, + Err: nil, + } + successfulGroupSettingsResponse := GroupSettingsResponse{ + GroupSettings: &admin.GroupSettings{}, + Err: nil, + } testCases := []struct { name string - mockResponses []ProjectResponse - teamRoleReponse ProjectResponse - limitResponse ProjectResponse - groupResponse ProjectResponse + teamRoleReponse TeamRoleResponse + groupResponse GroupSettingsResponse + limitResponse LimitsResponse expectedError bool }{ { name: "Successful", - teamRoleReponse: successfulPaginatedTeamRole, - limitResponse: successfulDataFederationLimit, + teamRoleReponse: successfulTeamRoleResponse, + limitResponse: successfulLimitsResponse, groupResponse: successfulGroupSettingsResponse, expectedError: false, }, { name: "Fail to get project's teams assigned ", - teamRoleReponse: ProjectResponse{ - ProjectTeamResp: nil, - HTTPResponse: &http.Response{StatusCode: 503}, - Err: errors.New("Service Unavailable"), + teamRoleReponse: TeamRoleResponse{ + TeamRole: nil, + HTTPResponse: &http.Response{StatusCode: 503}, + Err: errors.New("Service Unavailable"), }, expectedError: true, }, { name: "Fail to get project's limits", - teamRoleReponse: successfulPaginatedTeamRole, - limitResponse: ProjectResponse{ - LimitsResponse: nil, - HTTPResponse: &http.Response{StatusCode: 503}, - Err: errors.New("Service Unavailable"), + teamRoleReponse: successfulTeamRoleResponse, + limitResponse: LimitsResponse{ + Limits: nil, + HTTPResponse: &http.Response{StatusCode: 503}, + Err: errors.New("Service Unavailable"), }, expectedError: true, }, { name: "Fail to get project's settings", - teamRoleReponse: successfulPaginatedTeamRole, - limitResponse: successfulDataFederationLimit, - groupResponse: ProjectResponse{ - GroupSettingsResponse: nil, - HTTPResponse: &http.Response{StatusCode: 503}, - Err: errors.New("Service Unavailable"), + teamRoleReponse: successfulTeamRoleResponse, + limitResponse: successfulLimitsResponse, + groupResponse: GroupSettingsResponse{ + GroupSettings: nil, + HTTPResponse: &http.Response{StatusCode: 503}, + Err: errors.New("Service Unavailable"), }, expectedError: true, }, @@ -95,11 +94,12 @@ func TestGetProjectPropsFromAPI(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - testObject := new(MockProjectService) - testObject.On("ListProjectTeams", mock.Anything, mock.Anything).Return(tc.teamRoleReponse) - testObject.On("ListProjectLimits", mock.Anything, mock.Anything).Return(tc.limitResponse) - testObject.On("GetProjectSettings", mock.Anything, mock.Anything).Return(tc.groupResponse) - _, _, _, err := project.GetProjectPropsFromAPI(context.Background(), testObject, dummyProjectID) + svc := mocksvc.NewGroupProjectService(t) + svc.On("ListProjectTeams", mock.Anything, mock.Anything).Return(tc.teamRoleReponse.TeamRole, tc.teamRoleReponse.HTTPResponse, tc.teamRoleReponse.Err) + svc.On("ListProjectLimits", mock.Anything, mock.Anything).Return(tc.limitResponse.Limits, tc.limitResponse.HTTPResponse, tc.limitResponse.Err).Maybe() + svc.On("GetProjectSettings", mock.Anything, mock.Anything).Return(tc.groupResponse.GroupSettings, tc.groupResponse.HTTPResponse, tc.groupResponse.Err).Maybe() + + _, _, _, err := project.GetProjectPropsFromAPI(context.Background(), svc, dummyProjectID) if (err != nil) != tc.expectedError { t.Errorf("Case %s: Received unexpected error: %v", tc.name, err) @@ -158,7 +158,7 @@ func TestFilterUserDefinedLimits(t *testing.T) { func TestUpdateProject(t *testing.T) { testCases := []struct { name string - mockResponses []ProjectResponse + mockResponses ProjectResponse projectState project.TfProjectRSModel projectPlan project.TfProjectRSModel expectedError bool @@ -167,10 +167,8 @@ func TestUpdateProject(t *testing.T) { name: "Successful update", projectState: projectStateName, projectPlan: projectStateNameDiff, - mockResponses: []ProjectResponse{ - { - Err: nil, - }, + mockResponses: ProjectResponse{ + Err: nil, }, expectedError: false, }, @@ -178,10 +176,8 @@ func TestUpdateProject(t *testing.T) { name: "Same project names; No update", projectState: projectStateName, projectPlan: projectStateName, - mockResponses: []ProjectResponse{ - { - Err: nil, - }, + mockResponses: ProjectResponse{ + Err: nil, }, expectedError: false, }, @@ -189,12 +185,10 @@ func TestUpdateProject(t *testing.T) { name: "Failed API call; Failed update", projectState: projectStateName, projectPlan: projectStateNameDiff, - mockResponses: []ProjectResponse{ - { - ProjectResp: nil, - HTTPResponse: &http.Response{StatusCode: 503}, - Err: errors.New("Service Unavailable"), - }, + mockResponses: ProjectResponse{ + Project: nil, + HTTPResponse: &http.Response{StatusCode: 503}, + Err: errors.New("Service Unavailable"), }, expectedError: true, }, @@ -202,10 +196,11 @@ func TestUpdateProject(t *testing.T) { for i, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - testObject := new(MockProjectService) - testObject.On("UpdateProject", mock.Anything, mock.Anything).Return(tc.mockResponses[0]) + svc := mocksvc.NewGroupProjectService(t) + + svc.On("UpdateProject", mock.Anything, mock.Anything, mock.Anything).Return(tc.mockResponses.Project, tc.mockResponses.HTTPResponse, tc.mockResponses.Err).Maybe() - err := project.UpdateProject(context.Background(), testObject, &testCases[i].projectState, &testCases[i].projectPlan) + err := project.UpdateProject(context.Background(), svc, &testCases[i].projectState, &testCases[i].projectPlan) if (err != nil) != tc.expectedError { t.Errorf("Case %s: Received unexpected error: %v", tc.name, err) @@ -239,7 +234,7 @@ func TestUpdateProjectLimits(t *testing.T) { twoLimitSet, _ := types.SetValueFrom(context.Background(), project.TfLimitObjectType, twoLimits) testCases := []struct { name string - mockResponses []ProjectResponse + mockResponses DeleteProjectLimitResponse projectState project.TfProjectRSModel projectPlan project.TfProjectRSModel expectedError bool @@ -254,7 +249,7 @@ func TestUpdateProjectLimits(t *testing.T) { Name: name, Limits: singleLimitSet, }, - mockResponses: []ProjectResponse{{}}, + mockResponses: DeleteProjectLimitResponse{}, expectedError: false, }, { @@ -267,10 +262,8 @@ func TestUpdateProjectLimits(t *testing.T) { Name: name, Limits: twoLimitSet, }, - mockResponses: []ProjectResponse{ - { - Err: nil, - }, + mockResponses: DeleteProjectLimitResponse{ + Err: nil, }, expectedError: false, }, @@ -284,10 +277,8 @@ func TestUpdateProjectLimits(t *testing.T) { Name: name, Limits: singleLimitSet, }, - mockResponses: []ProjectResponse{ - { - Err: nil, - }, + mockResponses: DeleteProjectLimitResponse{ + Err: nil, }, expectedError: false, }, @@ -301,10 +292,8 @@ func TestUpdateProjectLimits(t *testing.T) { Name: name, Limits: updatedLimitSet, }, - mockResponses: []ProjectResponse{ - { - Err: nil, - }, + mockResponses: DeleteProjectLimitResponse{ + Err: nil, }, expectedError: false, }, @@ -312,12 +301,12 @@ func TestUpdateProjectLimits(t *testing.T) { for i, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - testObject := new(MockProjectService) + svc := mocksvc.NewGroupProjectService(t) - testObject.On("DeleteProjectLimit", mock.Anything, mock.Anything, mock.Anything).Return(tc.mockResponses[0]) - testObject.On("SetProjectLimit", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tc.mockResponses[0]) + svc.On("DeleteProjectLimit", mock.Anything, mock.Anything, mock.Anything).Return(tc.mockResponses.DeleteProjectLimit, tc.mockResponses.HTTPResponse, tc.mockResponses.Err).Maybe() + svc.On("SetProjectLimit", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, nil, nil).Maybe() - err := project.UpdateProjectLimits(context.Background(), testObject, &testCases[i].projectState, &testCases[i].projectPlan) + err := project.UpdateProjectLimits(context.Background(), svc, &testCases[i].projectState, &testCases[i].projectPlan) if (err != nil) != tc.expectedError { t.Errorf("Case %s: Received unexpected error: %v", tc.name, err) @@ -346,7 +335,6 @@ func TestUpdateProjectTeams(t *testing.T) { testCases := []struct { name string - mockResponses []ProjectResponse projectState project.TfProjectRSModel projectPlan project.TfProjectRSModel expectedError bool @@ -403,13 +391,13 @@ func TestUpdateProjectTeams(t *testing.T) { for i, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - testObject := new(MockProjectService) + svc := mocksvc.NewGroupProjectService(t) - testObject.On("AddAllTeamsToProject", mock.Anything, mock.Anything, mock.Anything).Return(ProjectResponse{Err: nil}) - testObject.On("RemoveProjectTeam", mock.Anything, mock.Anything, mock.Anything).Return(ProjectResponse{Err: nil}) - testObject.On("UpdateTeamRoles", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(ProjectResponse{Err: nil}) + svc.On("AddAllTeamsToProject", mock.Anything, mock.Anything, mock.Anything).Return(nil, nil, nil).Maybe() + svc.On("RemoveProjectTeam", mock.Anything, mock.Anything, mock.Anything).Return(nil, nil, nil).Maybe() + svc.On("UpdateTeamRoles", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, nil, nil).Maybe() - err := project.UpdateProjectTeams(context.Background(), testObject, &testCases[i].projectState, &testCases[i].projectPlan) + err := project.UpdateProjectTeams(context.Background(), svc, &testCases[i].projectState, &testCases[i].projectPlan) if (err != nil) != tc.expectedError { t.Errorf("Case %s: Received unexpected error: %v", tc.name, err) @@ -420,30 +408,30 @@ func TestUpdateProjectTeams(t *testing.T) { func TestResourceProjectDependentsDeletingRefreshFunc(t *testing.T) { testCases := []struct { + mockResponses AdvancedClusterDescriptionResponse name string - mockResponses ProjectResponse expectedError bool }{ { name: "Error not from the API", - mockResponses: ProjectResponse{ - clusterReponse: &admin.PaginatedAdvancedClusterDescription{}, - Err: errors.New("Non-API error"), + mockResponses: AdvancedClusterDescriptionResponse{ + AdvancedClusterDescription: &admin.PaginatedAdvancedClusterDescription{}, + Err: errors.New("Non-API error"), }, expectedError: true, }, { name: "Error from the API", - mockResponses: ProjectResponse{ - clusterReponse: &admin.PaginatedAdvancedClusterDescription{}, - Err: &admin.GenericOpenAPIError{}, + mockResponses: AdvancedClusterDescriptionResponse{ + AdvancedClusterDescription: &admin.PaginatedAdvancedClusterDescription{}, + Err: &admin.GenericOpenAPIError{}, }, expectedError: true, }, { name: "Successful API call", - mockResponses: ProjectResponse{ - clusterReponse: &admin.PaginatedAdvancedClusterDescription{ + mockResponses: AdvancedClusterDescriptionResponse{ + AdvancedClusterDescription: &admin.PaginatedAdvancedClusterDescription{ TotalCount: conversion.IntPtr(2), Results: []admin.AdvancedClusterDescription{ {StateName: conversion.StringPtr("IDLE")}, @@ -458,11 +446,11 @@ func TestResourceProjectDependentsDeletingRefreshFunc(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - testObject := new(MockProjectService) + svc := mocksvc.NewGroupProjectService(t) - testObject.On("ListClusters", mock.Anything, dummyProjectID).Return(tc.mockResponses) + svc.On("ListClusters", mock.Anything, dummyProjectID).Return(tc.mockResponses.AdvancedClusterDescription, tc.mockResponses.HTTPResponse, tc.mockResponses.Err) - _, _, err := project.ResourceProjectDependentsDeletingRefreshFunc(context.Background(), dummyProjectID, testObject)() + _, _, err := project.ResourceProjectDependentsDeletingRefreshFunc(context.Background(), dummyProjectID, svc)() if (err != nil) != tc.expectedError { t.Errorf("Case %s: Received unexpected error: %v", tc.name, err) @@ -895,79 +883,33 @@ func createDataFederationLimit(limitName string) admin.DataFederationLimit { } } -type MockProjectService struct { - mock.Mock - MockResponses []ProjectResponse -} - -func (a *MockProjectService) UpdateProject(ctx context.Context, groupID string, groupName *admin.GroupName) (*admin.Group, *http.Response, error) { - args := a.Called(ctx, groupID) - var response = args.Get(0).(ProjectResponse) - return response.ProjectResp, response.HTTPResponse, response.Err -} - -func (a *MockProjectService) ListProjectLimits(ctx context.Context, groupID string) ([]admin.DataFederationLimit, *http.Response, error) { - args := a.Called(ctx, groupID) - var response = args.Get(0).(ProjectResponse) - return response.LimitsResponse, response.HTTPResponse, response.Err -} - -func (a *MockProjectService) GetProjectSettings(ctx context.Context, groupID string) (*admin.GroupSettings, *http.Response, error) { - args := a.Called(ctx, groupID) - var response = args.Get(0).(ProjectResponse) - return response.GroupSettingsResponse, response.HTTPResponse, response.Err +type TeamRoleResponse struct { + TeamRole *admin.PaginatedTeamRole + HTTPResponse *http.Response + Err error } - -func (a *MockProjectService) ListProjectTeams(ctx context.Context, groupID string) (*admin.PaginatedTeamRole, *http.Response, error) { - args := a.Called(ctx, groupID) - var response = args.Get(0).(ProjectResponse) - return response.ProjectTeamResp, response.HTTPResponse, response.Err -} - -func (a *MockProjectService) DeleteProjectLimit(ctx context.Context, limitName, projectID string) (map[string]interface{}, *http.Response, error) { - args := a.Called(ctx, limitName, projectID) - var response = args.Get(0).(ProjectResponse) - return response.DeleteProjectLimitResponse, response.HTTPResponse, response.Err +type LimitsResponse struct { + Err error + HTTPResponse *http.Response + Limits []admin.DataFederationLimit } - -func (a *MockProjectService) SetProjectLimit(ctx context.Context, limitName, groupID string, dataFederationLimit *admin.DataFederationLimit) (*admin.DataFederationLimit, *http.Response, error) { - args := a.Called(ctx, limitName, groupID, dataFederationLimit) - var response = args.Get(0).(ProjectResponse) - return &response.LimitResponse, response.HTTPResponse, response.Err +type GroupSettingsResponse struct { + GroupSettings *admin.GroupSettings + HTTPResponse *http.Response + Err error } - -func (a *MockProjectService) RemoveProjectTeam(ctx context.Context, groupID, teamID string) (*http.Response, error) { - args := a.Called(ctx, groupID, teamID) - var response = args.Get(0).(ProjectResponse) - return response.HTTPResponse, response.Err -} - -func (a *MockProjectService) UpdateTeamRoles(ctx context.Context, groupID, teamID string, teamRole *admin.TeamRole) (*admin.PaginatedTeamRole, *http.Response, error) { - args := a.Called(ctx, groupID, teamID, teamRole) - var response = args.Get(0).(ProjectResponse) - return response.ProjectTeamResp, response.HTTPResponse, response.Err -} - -func (a *MockProjectService) AddAllTeamsToProject(ctx context.Context, groupID string, teamRole *[]admin.TeamRole) (*admin.PaginatedTeamRole, *http.Response, error) { - args := a.Called(ctx, groupID, teamRole) - var response = args.Get(0).(ProjectResponse) - return response.ProjectTeamResp, response.HTTPResponse, response.Err +type ProjectResponse struct { + Project *admin.Group + HTTPResponse *http.Response + Err error } - -func (a *MockProjectService) ListClusters(ctx context.Context, groupID string) (*admin.PaginatedAdvancedClusterDescription, *http.Response, error) { - args := a.Called(ctx, groupID) - var response = args.Get(0).(ProjectResponse) - return response.clusterReponse, response.HTTPResponse, response.Err +type DeleteProjectLimitResponse struct { + DeleteProjectLimit map[string]interface{} + HTTPResponse *http.Response + Err error } - -type ProjectResponse struct { - ProjectResp *admin.Group - ProjectTeamResp *admin.PaginatedTeamRole - GroupSettingsResponse *admin.GroupSettings - clusterReponse *admin.PaginatedAdvancedClusterDescription +type AdvancedClusterDescriptionResponse struct { + AdvancedClusterDescription *admin.PaginatedAdvancedClusterDescription HTTPResponse *http.Response Err error - LimitResponse admin.DataFederationLimit - DeleteProjectLimitResponse map[string]interface{} - LimitsResponse []admin.DataFederationLimit } diff --git a/internal/testutil/mocksvc/group_project_service.go b/internal/testutil/mocksvc/group_project_service.go new file mode 100644 index 0000000000..3b7a4b31d8 --- /dev/null +++ b/internal/testutil/mocksvc/group_project_service.go @@ -0,0 +1,413 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocksvc + +import ( + context "context" + + admin "go.mongodb.org/atlas-sdk/v20231115002/admin" + + http "net/http" + + mock "github.com/stretchr/testify/mock" +) + +// GroupProjectService is an autogenerated mock type for the GroupProjectService type +type GroupProjectService struct { + mock.Mock +} + +// AddAllTeamsToProject provides a mock function with given fields: ctx, groupID, teamRole +func (_m *GroupProjectService) AddAllTeamsToProject(ctx context.Context, groupID string, teamRole *[]admin.TeamRole) (*admin.PaginatedTeamRole, *http.Response, error) { + ret := _m.Called(ctx, groupID, teamRole) + + if len(ret) == 0 { + panic("no return value specified for AddAllTeamsToProject") + } + + var r0 *admin.PaginatedTeamRole + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, *[]admin.TeamRole) (*admin.PaginatedTeamRole, *http.Response, error)); ok { + return rf(ctx, groupID, teamRole) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *[]admin.TeamRole) *admin.PaginatedTeamRole); ok { + r0 = rf(ctx, groupID, teamRole) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*admin.PaginatedTeamRole) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *[]admin.TeamRole) *http.Response); ok { + r1 = rf(ctx, groupID, teamRole) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, *[]admin.TeamRole) error); ok { + r2 = rf(ctx, groupID, teamRole) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// DeleteProjectLimit provides a mock function with given fields: ctx, limitName, projectID +func (_m *GroupProjectService) DeleteProjectLimit(ctx context.Context, limitName string, projectID string) (map[string]interface{}, *http.Response, error) { + ret := _m.Called(ctx, limitName, projectID) + + if len(ret) == 0 { + panic("no return value specified for DeleteProjectLimit") + } + + var r0 map[string]interface{} + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (map[string]interface{}, *http.Response, error)); ok { + return rf(ctx, limitName, projectID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) map[string]interface{}); ok { + r0 = rf(ctx, limitName, projectID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]interface{}) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) *http.Response); ok { + r1 = rf(ctx, limitName, projectID) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, string) error); ok { + r2 = rf(ctx, limitName, projectID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// GetProjectSettings provides a mock function with given fields: ctx, groupID +func (_m *GroupProjectService) GetProjectSettings(ctx context.Context, groupID string) (*admin.GroupSettings, *http.Response, error) { + ret := _m.Called(ctx, groupID) + + if len(ret) == 0 { + panic("no return value specified for GetProjectSettings") + } + + var r0 *admin.GroupSettings + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*admin.GroupSettings, *http.Response, error)); ok { + return rf(ctx, groupID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *admin.GroupSettings); ok { + r0 = rf(ctx, groupID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*admin.GroupSettings) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *http.Response); ok { + r1 = rf(ctx, groupID) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, groupID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// ListClusters provides a mock function with given fields: ctx, groupID +func (_m *GroupProjectService) ListClusters(ctx context.Context, groupID string) (*admin.PaginatedAdvancedClusterDescription, *http.Response, error) { + ret := _m.Called(ctx, groupID) + + if len(ret) == 0 { + panic("no return value specified for ListClusters") + } + + var r0 *admin.PaginatedAdvancedClusterDescription + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*admin.PaginatedAdvancedClusterDescription, *http.Response, error)); ok { + return rf(ctx, groupID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *admin.PaginatedAdvancedClusterDescription); ok { + r0 = rf(ctx, groupID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*admin.PaginatedAdvancedClusterDescription) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *http.Response); ok { + r1 = rf(ctx, groupID) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, groupID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// ListProjectLimits provides a mock function with given fields: ctx, groupID +func (_m *GroupProjectService) ListProjectLimits(ctx context.Context, groupID string) ([]admin.DataFederationLimit, *http.Response, error) { + ret := _m.Called(ctx, groupID) + + if len(ret) == 0 { + panic("no return value specified for ListProjectLimits") + } + + var r0 []admin.DataFederationLimit + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) ([]admin.DataFederationLimit, *http.Response, error)); ok { + return rf(ctx, groupID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) []admin.DataFederationLimit); ok { + r0 = rf(ctx, groupID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]admin.DataFederationLimit) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *http.Response); ok { + r1 = rf(ctx, groupID) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, groupID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// ListProjectTeams provides a mock function with given fields: ctx, groupID +func (_m *GroupProjectService) ListProjectTeams(ctx context.Context, groupID string) (*admin.PaginatedTeamRole, *http.Response, error) { + ret := _m.Called(ctx, groupID) + + if len(ret) == 0 { + panic("no return value specified for ListProjectTeams") + } + + var r0 *admin.PaginatedTeamRole + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*admin.PaginatedTeamRole, *http.Response, error)); ok { + return rf(ctx, groupID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *admin.PaginatedTeamRole); ok { + r0 = rf(ctx, groupID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*admin.PaginatedTeamRole) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *http.Response); ok { + r1 = rf(ctx, groupID) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, groupID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// RemoveProjectTeam provides a mock function with given fields: ctx, groupID, teamID +func (_m *GroupProjectService) RemoveProjectTeam(ctx context.Context, groupID string, teamID string) (*http.Response, error) { + ret := _m.Called(ctx, groupID, teamID) + + if len(ret) == 0 { + panic("no return value specified for RemoveProjectTeam") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*http.Response, error)); ok { + return rf(ctx, groupID, teamID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) *http.Response); ok { + r0 = rf(ctx, groupID, teamID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, groupID, teamID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SetProjectLimit provides a mock function with given fields: ctx, limitName, groupID, dataFederationLimit +func (_m *GroupProjectService) SetProjectLimit(ctx context.Context, limitName string, groupID string, dataFederationLimit *admin.DataFederationLimit) (*admin.DataFederationLimit, *http.Response, error) { + ret := _m.Called(ctx, limitName, groupID, dataFederationLimit) + + if len(ret) == 0 { + panic("no return value specified for SetProjectLimit") + } + + var r0 *admin.DataFederationLimit + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *admin.DataFederationLimit) (*admin.DataFederationLimit, *http.Response, error)); ok { + return rf(ctx, limitName, groupID, dataFederationLimit) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, *admin.DataFederationLimit) *admin.DataFederationLimit); ok { + r0 = rf(ctx, limitName, groupID, dataFederationLimit) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*admin.DataFederationLimit) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, *admin.DataFederationLimit) *http.Response); ok { + r1 = rf(ctx, limitName, groupID, dataFederationLimit) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, string, *admin.DataFederationLimit) error); ok { + r2 = rf(ctx, limitName, groupID, dataFederationLimit) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// UpdateProject provides a mock function with given fields: ctx, groupID, groupName +func (_m *GroupProjectService) UpdateProject(ctx context.Context, groupID string, groupName *admin.GroupName) (*admin.Group, *http.Response, error) { + ret := _m.Called(ctx, groupID, groupName) + + if len(ret) == 0 { + panic("no return value specified for UpdateProject") + } + + var r0 *admin.Group + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, *admin.GroupName) (*admin.Group, *http.Response, error)); ok { + return rf(ctx, groupID, groupName) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *admin.GroupName) *admin.Group); ok { + r0 = rf(ctx, groupID, groupName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*admin.Group) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *admin.GroupName) *http.Response); ok { + r1 = rf(ctx, groupID, groupName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, *admin.GroupName) error); ok { + r2 = rf(ctx, groupID, groupName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// UpdateTeamRoles provides a mock function with given fields: ctx, groupID, teamID, teamRole +func (_m *GroupProjectService) UpdateTeamRoles(ctx context.Context, groupID string, teamID string, teamRole *admin.TeamRole) (*admin.PaginatedTeamRole, *http.Response, error) { + ret := _m.Called(ctx, groupID, teamID, teamRole) + + if len(ret) == 0 { + panic("no return value specified for UpdateTeamRoles") + } + + var r0 *admin.PaginatedTeamRole + var r1 *http.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *admin.TeamRole) (*admin.PaginatedTeamRole, *http.Response, error)); ok { + return rf(ctx, groupID, teamID, teamRole) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, *admin.TeamRole) *admin.PaginatedTeamRole); ok { + r0 = rf(ctx, groupID, teamID, teamRole) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*admin.PaginatedTeamRole) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, *admin.TeamRole) *http.Response); ok { + r1 = rf(ctx, groupID, teamID, teamRole) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*http.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, string, *admin.TeamRole) error); ok { + r2 = rf(ctx, groupID, teamID, teamRole) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// NewGroupProjectService creates a new instance of GroupProjectService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewGroupProjectService(t interface { + mock.TestingT + Cleanup(func()) +}) *GroupProjectService { + mock := &GroupProjectService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}