Loading integrations.go +83 −2 Original line number Diff line number Diff line Loading @@ -133,6 +133,25 @@ type ( // https://docs.gitlab.com/api/group_integrations/#google-chat GetGroupGoogleChatSettings(gid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) // SetProjectGoogleChatSettings sets up the Google Chat integration for a project. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#set-up-google-chat SetProjectGoogleChatSettings(pid any, opt *SetProjectGoogleChatOptions, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) // DisableProjectGoogleChat disables the Google Chat integration for a project. // Integration settings are reset. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#disable-google-chat DisableProjectGoogleChat(pid any, options ...RequestOptionFunc) (*Response, error) // GetProjectGoogleChatSettings gets the Google Chat integration settings for a project. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#get-google-chat-settings GetProjectGoogleChatSettings(pid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) // GetGroupMattermostIntegration retrieves the Mattermost integration for a group. // // GitLab API docs: Loading Loading @@ -363,7 +382,18 @@ type GoogleChatIntegration struct { // GoogleChatIntegrationProperties represents Google Chat specific properties. type GoogleChatIntegrationProperties struct { NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines,omitempty"` NotifyOnlyWhenPipelineStatusChanges bool `json:"notify_only_when_pipeline_status_changes,omitempty"` NotifyOnlyDefaultBranch bool `json:"notify_only_default_branch,omitempty"` BranchesToBeNotified string `json:"branches_to_be_notified,omitempty"` PushEvents bool `json:"push_events,omitempty"` IssuesEvents bool `json:"issues_events,omitempty"` ConfidentialIssuesEvents bool `json:"confidential_issues_events,omitempty"` MergeRequestsEvents bool `json:"merge_requests_events,omitempty"` TagPushEvents bool `json:"tag_push_events,omitempty"` NoteEvents bool `json:"note_events,omitempty"` ConfidentialNoteEvents bool `json:"confidential_note_events,omitempty"` PipelineEvents bool `json:"pipeline_events,omitempty"` WikiPageEvents bool `json:"wiki_page_events,omitempty"` } // WebexTeamsIntegration represents the WebexTeams integration settings. Loading @@ -390,6 +420,28 @@ type SetGroupWebexTeamsOptions struct { BranchesToBeNotified *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"` } // SetProjectGoogleChatOptions represents the available SetProjectGoogleChatSettings() options. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#set-up-google-chat type SetProjectGoogleChatOptions struct { Webhook *string `url:"webhook,omitempty" json:"webhook,omitempty"` NotifyOnlyBrokenPipelines *bool `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"` NotifyOnlyWhenPipelineStatusChanges *bool `url:"notify_only_when_pipeline_status_changes,omitempty" json:"notify_only_when_pipeline_status_changes,omitempty"` NotifyOnlyDefaultBranch *bool `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"` BranchesToBeNotified *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"` PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` IssuesEvents *bool `url:"issues_events,omitempty" json:"issues_events,omitempty"` ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` NoteEvents *bool `url:"note_events,omitempty" json:"note_events,omitempty"` ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"` PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"` WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"` UseInheritedSettings *bool `url:"use_inherited_settings,omitempty" json:"use_inherited_settings,omitempty"` } // ListActiveIntegrationsOptions represents the available // ListActiveIntegrations() options. // Loading Loading @@ -657,6 +709,35 @@ func (s *IntegrationsService) GetGroupGoogleChatSettings(gid any, options ...Req ) } func (s *IntegrationsService) SetProjectGoogleChatSettings(pid any, opt *SetProjectGoogleChatOptions, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) { return do[*GoogleChatIntegration]( s.client, withPath("projects/%s/integrations/hangouts-chat", ProjectID{pid}), withMethod(http.MethodPut), withAPIOpts(opt), withRequestOpts(options...), ) } func (s *IntegrationsService) DisableProjectGoogleChat(pid any, options ...RequestOptionFunc) (*Response, error) { _, resp, err := do[none]( s.client, withPath("projects/%s/integrations/hangouts-chat", ProjectID{pid}), withMethod(http.MethodDelete), withRequestOpts(options...), ) return resp, err } func (s *IntegrationsService) GetProjectGoogleChatSettings(pid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) { return do[*GoogleChatIntegration]( s.client, withPath("projects/%s/integrations/hangouts-chat", ProjectID{pid}), withMethod(http.MethodGet), withRequestOpts(options...), ) } func (s *IntegrationsService) GetGroupWebexTeamsSettings(gid any, options ...RequestOptionFunc) (*WebexTeamsIntegration, *Response, error) { return do[*WebexTeamsIntegration]( s.client, Loading integrations_test.go +72 −0 Original line number Diff line number Diff line Loading @@ -1023,3 +1023,75 @@ func TestDisableGroupWebexTeams(t *testing.T) { require.NoError(t, err) assert.NotNil(t, resp) } func TestSetProjectGoogleChatSettings(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/integrations/hangouts-chat", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) testBodyJSON(t, r, map[string]any{ "webhook": "https://chat.googleapis.com/v1/spaces/XXXXXX", "notify_only_broken_pipelines": true, "branches_to_be_notified": "default", }) fmt.Fprint(w, `{ "id": 1, "title": "Google Chat", "slug": "hangouts-chat", "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-02T00:00:00.000Z", "active": true, "properties": { "notify_only_broken_pipelines": true, "branches_to_be_notified": "default" } }`) }) opt := &SetProjectGoogleChatOptions{ Webhook: Ptr("https://chat.googleapis.com/v1/spaces/XXXXXX"), NotifyOnlyBrokenPipelines: Ptr(true), BranchesToBeNotified: Ptr("default"), } integration, resp, err := client.Integrations.SetProjectGoogleChatSettings(1, opt) assert.NoError(t, err) assert.NotNil(t, resp) assert.Equal(t, "Google Chat", integration.Title) } func TestDisableProjectGoogleChat(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/integrations/hangouts-chat", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) resp, err := client.Integrations.DisableProjectGoogleChat(1) assert.NoError(t, err) assert.NotNil(t, resp) } func TestGetProjectGoogleChatSettings(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/integrations/hangouts-chat", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "id": 1, "title": "Google Chat", "slug": "hangouts-chat", "properties": { "branches_to_be_notified": "default" } }`) }) integration, resp, err := client.Integrations.GetProjectGoogleChatSettings(1) assert.NoError(t, err) assert.NotNil(t, resp) assert.Equal(t, "default", integration.Properties.BranchesToBeNotified) } testing/integrations_mock.go +134 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,50 @@ func (c *MockIntegrationsServiceInterfaceDisableGroupWebexTeamsCall) DoAndReturn return c } // DisableProjectGoogleChat mocks base method. func (m *MockIntegrationsServiceInterface) DisableProjectGoogleChat(pid any, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "DisableProjectGoogleChat", varargs...) ret0, _ := ret[0].(*gitlab.Response) ret1, _ := ret[1].(error) return ret0, ret1 } // DisableProjectGoogleChat indicates an expected call of DisableProjectGoogleChat. func (mr *MockIntegrationsServiceInterfaceMockRecorder) DisableProjectGoogleChat(pid any, options ...any) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DisableProjectGoogleChat", reflect.TypeOf((*MockIntegrationsServiceInterface)(nil).DisableProjectGoogleChat), varargs...) return &MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall{Call: call} } // MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall wrap *gomock.Call type MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall) Return(arg0 *gitlab.Response, arg1 error) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { c.Call = c.Call.Return(arg0, arg1) return c } // Do rewrite *gomock.Call.Do func (c *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall) Do(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall) DoAndReturn(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { c.Call = c.Call.DoAndReturn(f) return c } // GetGroupDiscordSettings mocks base method. func (m *MockIntegrationsServiceInterface) GetGroupDiscordSettings(gid any, options ...gitlab.RequestOptionFunc) (*gitlab.DiscordIntegration, *gitlab.Response, error) { m.ctrl.T.Helper() Loading Loading @@ -887,6 +931,51 @@ func (c *MockIntegrationsServiceInterfaceGetGroupWebexTeamsSettingsCall) DoAndRe return c } // GetProjectGoogleChatSettings mocks base method. func (m *MockIntegrationsServiceInterface) GetProjectGoogleChatSettings(pid any, options ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "GetProjectGoogleChatSettings", varargs...) ret0, _ := ret[0].(*gitlab.GoogleChatIntegration) ret1, _ := ret[1].(*gitlab.Response) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } // GetProjectGoogleChatSettings indicates an expected call of GetProjectGoogleChatSettings. func (mr *MockIntegrationsServiceInterfaceMockRecorder) GetProjectGoogleChatSettings(pid any, options ...any) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectGoogleChatSettings", reflect.TypeOf((*MockIntegrationsServiceInterface)(nil).GetProjectGoogleChatSettings), varargs...) return &MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall{Call: call} } // MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall wrap *gomock.Call type MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall) Return(arg0 *gitlab.GoogleChatIntegration, arg1 *gitlab.Response, arg2 error) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { c.Call = c.Call.Return(arg0, arg1, arg2) return c } // Do rewrite *gomock.Call.Do func (c *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall) Do(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall) DoAndReturn(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { c.Call = c.Call.DoAndReturn(f) return c } // ListActiveGroupIntegrations mocks base method. func (m *MockIntegrationsServiceInterface) ListActiveGroupIntegrations(gid any, opt *gitlab.ListActiveIntegrationsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Integration, *gitlab.Response, error) { m.ctrl.T.Helper() Loading Loading @@ -1157,6 +1246,51 @@ func (c *MockIntegrationsServiceInterfaceSetGroupWebexTeamsSettingsCall) DoAndRe return c } // SetProjectGoogleChatSettings mocks base method. func (m *MockIntegrationsServiceInterface) SetProjectGoogleChatSettings(pid any, opt *gitlab.SetProjectGoogleChatOptions, options ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid, opt} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "SetProjectGoogleChatSettings", varargs...) ret0, _ := ret[0].(*gitlab.GoogleChatIntegration) ret1, _ := ret[1].(*gitlab.Response) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } // SetProjectGoogleChatSettings indicates an expected call of SetProjectGoogleChatSettings. func (mr *MockIntegrationsServiceInterfaceMockRecorder) SetProjectGoogleChatSettings(pid, opt any, options ...any) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid, opt}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProjectGoogleChatSettings", reflect.TypeOf((*MockIntegrationsServiceInterface)(nil).SetProjectGoogleChatSettings), varargs...) return &MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall{Call: call} } // MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall wrap *gomock.Call type MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall) Return(arg0 *gitlab.GoogleChatIntegration, arg1 *gitlab.Response, arg2 error) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { c.Call = c.Call.Return(arg0, arg1, arg2) return c } // Do rewrite *gomock.Call.Do func (c *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall) Do(f func(any, *gitlab.SetProjectGoogleChatOptions, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall) DoAndReturn(f func(any, *gitlab.SetProjectGoogleChatOptions, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { c.Call = c.Call.DoAndReturn(f) return c } // SetUpGroupHarbor mocks base method. func (m *MockIntegrationsServiceInterface) SetUpGroupHarbor(gid any, opt *gitlab.SetUpHarborOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Integration, *gitlab.Response, error) { m.ctrl.T.Helper() Loading Loading
integrations.go +83 −2 Original line number Diff line number Diff line Loading @@ -133,6 +133,25 @@ type ( // https://docs.gitlab.com/api/group_integrations/#google-chat GetGroupGoogleChatSettings(gid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) // SetProjectGoogleChatSettings sets up the Google Chat integration for a project. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#set-up-google-chat SetProjectGoogleChatSettings(pid any, opt *SetProjectGoogleChatOptions, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) // DisableProjectGoogleChat disables the Google Chat integration for a project. // Integration settings are reset. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#disable-google-chat DisableProjectGoogleChat(pid any, options ...RequestOptionFunc) (*Response, error) // GetProjectGoogleChatSettings gets the Google Chat integration settings for a project. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#get-google-chat-settings GetProjectGoogleChatSettings(pid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) // GetGroupMattermostIntegration retrieves the Mattermost integration for a group. // // GitLab API docs: Loading Loading @@ -363,7 +382,18 @@ type GoogleChatIntegration struct { // GoogleChatIntegrationProperties represents Google Chat specific properties. type GoogleChatIntegrationProperties struct { NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines,omitempty"` NotifyOnlyWhenPipelineStatusChanges bool `json:"notify_only_when_pipeline_status_changes,omitempty"` NotifyOnlyDefaultBranch bool `json:"notify_only_default_branch,omitempty"` BranchesToBeNotified string `json:"branches_to_be_notified,omitempty"` PushEvents bool `json:"push_events,omitempty"` IssuesEvents bool `json:"issues_events,omitempty"` ConfidentialIssuesEvents bool `json:"confidential_issues_events,omitempty"` MergeRequestsEvents bool `json:"merge_requests_events,omitempty"` TagPushEvents bool `json:"tag_push_events,omitempty"` NoteEvents bool `json:"note_events,omitempty"` ConfidentialNoteEvents bool `json:"confidential_note_events,omitempty"` PipelineEvents bool `json:"pipeline_events,omitempty"` WikiPageEvents bool `json:"wiki_page_events,omitempty"` } // WebexTeamsIntegration represents the WebexTeams integration settings. Loading @@ -390,6 +420,28 @@ type SetGroupWebexTeamsOptions struct { BranchesToBeNotified *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"` } // SetProjectGoogleChatOptions represents the available SetProjectGoogleChatSettings() options. // // GitLab API docs: // https://docs.gitlab.com/api/integrations.html#set-up-google-chat type SetProjectGoogleChatOptions struct { Webhook *string `url:"webhook,omitempty" json:"webhook,omitempty"` NotifyOnlyBrokenPipelines *bool `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"` NotifyOnlyWhenPipelineStatusChanges *bool `url:"notify_only_when_pipeline_status_changes,omitempty" json:"notify_only_when_pipeline_status_changes,omitempty"` NotifyOnlyDefaultBranch *bool `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"` BranchesToBeNotified *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"` PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` IssuesEvents *bool `url:"issues_events,omitempty" json:"issues_events,omitempty"` ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` NoteEvents *bool `url:"note_events,omitempty" json:"note_events,omitempty"` ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"` PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"` WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"` UseInheritedSettings *bool `url:"use_inherited_settings,omitempty" json:"use_inherited_settings,omitempty"` } // ListActiveIntegrationsOptions represents the available // ListActiveIntegrations() options. // Loading Loading @@ -657,6 +709,35 @@ func (s *IntegrationsService) GetGroupGoogleChatSettings(gid any, options ...Req ) } func (s *IntegrationsService) SetProjectGoogleChatSettings(pid any, opt *SetProjectGoogleChatOptions, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) { return do[*GoogleChatIntegration]( s.client, withPath("projects/%s/integrations/hangouts-chat", ProjectID{pid}), withMethod(http.MethodPut), withAPIOpts(opt), withRequestOpts(options...), ) } func (s *IntegrationsService) DisableProjectGoogleChat(pid any, options ...RequestOptionFunc) (*Response, error) { _, resp, err := do[none]( s.client, withPath("projects/%s/integrations/hangouts-chat", ProjectID{pid}), withMethod(http.MethodDelete), withRequestOpts(options...), ) return resp, err } func (s *IntegrationsService) GetProjectGoogleChatSettings(pid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) { return do[*GoogleChatIntegration]( s.client, withPath("projects/%s/integrations/hangouts-chat", ProjectID{pid}), withMethod(http.MethodGet), withRequestOpts(options...), ) } func (s *IntegrationsService) GetGroupWebexTeamsSettings(gid any, options ...RequestOptionFunc) (*WebexTeamsIntegration, *Response, error) { return do[*WebexTeamsIntegration]( s.client, Loading
integrations_test.go +72 −0 Original line number Diff line number Diff line Loading @@ -1023,3 +1023,75 @@ func TestDisableGroupWebexTeams(t *testing.T) { require.NoError(t, err) assert.NotNil(t, resp) } func TestSetProjectGoogleChatSettings(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/integrations/hangouts-chat", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) testBodyJSON(t, r, map[string]any{ "webhook": "https://chat.googleapis.com/v1/spaces/XXXXXX", "notify_only_broken_pipelines": true, "branches_to_be_notified": "default", }) fmt.Fprint(w, `{ "id": 1, "title": "Google Chat", "slug": "hangouts-chat", "created_at": "2023-01-01T00:00:00.000Z", "updated_at": "2023-01-02T00:00:00.000Z", "active": true, "properties": { "notify_only_broken_pipelines": true, "branches_to_be_notified": "default" } }`) }) opt := &SetProjectGoogleChatOptions{ Webhook: Ptr("https://chat.googleapis.com/v1/spaces/XXXXXX"), NotifyOnlyBrokenPipelines: Ptr(true), BranchesToBeNotified: Ptr("default"), } integration, resp, err := client.Integrations.SetProjectGoogleChatSettings(1, opt) assert.NoError(t, err) assert.NotNil(t, resp) assert.Equal(t, "Google Chat", integration.Title) } func TestDisableProjectGoogleChat(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/integrations/hangouts-chat", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodDelete) }) resp, err := client.Integrations.DisableProjectGoogleChat(1) assert.NoError(t, err) assert.NotNil(t, resp) } func TestGetProjectGoogleChatSettings(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/integrations/hangouts-chat", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "id": 1, "title": "Google Chat", "slug": "hangouts-chat", "properties": { "branches_to_be_notified": "default" } }`) }) integration, resp, err := client.Integrations.GetProjectGoogleChatSettings(1) assert.NoError(t, err) assert.NotNil(t, resp) assert.Equal(t, "default", integration.Properties.BranchesToBeNotified) }
testing/integrations_mock.go +134 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,50 @@ func (c *MockIntegrationsServiceInterfaceDisableGroupWebexTeamsCall) DoAndReturn return c } // DisableProjectGoogleChat mocks base method. func (m *MockIntegrationsServiceInterface) DisableProjectGoogleChat(pid any, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "DisableProjectGoogleChat", varargs...) ret0, _ := ret[0].(*gitlab.Response) ret1, _ := ret[1].(error) return ret0, ret1 } // DisableProjectGoogleChat indicates an expected call of DisableProjectGoogleChat. func (mr *MockIntegrationsServiceInterfaceMockRecorder) DisableProjectGoogleChat(pid any, options ...any) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DisableProjectGoogleChat", reflect.TypeOf((*MockIntegrationsServiceInterface)(nil).DisableProjectGoogleChat), varargs...) return &MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall{Call: call} } // MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall wrap *gomock.Call type MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall) Return(arg0 *gitlab.Response, arg1 error) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { c.Call = c.Call.Return(arg0, arg1) return c } // Do rewrite *gomock.Call.Do func (c *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall) Do(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall) DoAndReturn(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockIntegrationsServiceInterfaceDisableProjectGoogleChatCall { c.Call = c.Call.DoAndReturn(f) return c } // GetGroupDiscordSettings mocks base method. func (m *MockIntegrationsServiceInterface) GetGroupDiscordSettings(gid any, options ...gitlab.RequestOptionFunc) (*gitlab.DiscordIntegration, *gitlab.Response, error) { m.ctrl.T.Helper() Loading Loading @@ -887,6 +931,51 @@ func (c *MockIntegrationsServiceInterfaceGetGroupWebexTeamsSettingsCall) DoAndRe return c } // GetProjectGoogleChatSettings mocks base method. func (m *MockIntegrationsServiceInterface) GetProjectGoogleChatSettings(pid any, options ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "GetProjectGoogleChatSettings", varargs...) ret0, _ := ret[0].(*gitlab.GoogleChatIntegration) ret1, _ := ret[1].(*gitlab.Response) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } // GetProjectGoogleChatSettings indicates an expected call of GetProjectGoogleChatSettings. func (mr *MockIntegrationsServiceInterfaceMockRecorder) GetProjectGoogleChatSettings(pid any, options ...any) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectGoogleChatSettings", reflect.TypeOf((*MockIntegrationsServiceInterface)(nil).GetProjectGoogleChatSettings), varargs...) return &MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall{Call: call} } // MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall wrap *gomock.Call type MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall) Return(arg0 *gitlab.GoogleChatIntegration, arg1 *gitlab.Response, arg2 error) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { c.Call = c.Call.Return(arg0, arg1, arg2) return c } // Do rewrite *gomock.Call.Do func (c *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall) Do(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall) DoAndReturn(f func(any, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceGetProjectGoogleChatSettingsCall { c.Call = c.Call.DoAndReturn(f) return c } // ListActiveGroupIntegrations mocks base method. func (m *MockIntegrationsServiceInterface) ListActiveGroupIntegrations(gid any, opt *gitlab.ListActiveIntegrationsOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Integration, *gitlab.Response, error) { m.ctrl.T.Helper() Loading Loading @@ -1157,6 +1246,51 @@ func (c *MockIntegrationsServiceInterfaceSetGroupWebexTeamsSettingsCall) DoAndRe return c } // SetProjectGoogleChatSettings mocks base method. func (m *MockIntegrationsServiceInterface) SetProjectGoogleChatSettings(pid any, opt *gitlab.SetProjectGoogleChatOptions, options ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid, opt} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "SetProjectGoogleChatSettings", varargs...) ret0, _ := ret[0].(*gitlab.GoogleChatIntegration) ret1, _ := ret[1].(*gitlab.Response) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } // SetProjectGoogleChatSettings indicates an expected call of SetProjectGoogleChatSettings. func (mr *MockIntegrationsServiceInterfaceMockRecorder) SetProjectGoogleChatSettings(pid, opt any, options ...any) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid, opt}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProjectGoogleChatSettings", reflect.TypeOf((*MockIntegrationsServiceInterface)(nil).SetProjectGoogleChatSettings), varargs...) return &MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall{Call: call} } // MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall wrap *gomock.Call type MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall) Return(arg0 *gitlab.GoogleChatIntegration, arg1 *gitlab.Response, arg2 error) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { c.Call = c.Call.Return(arg0, arg1, arg2) return c } // Do rewrite *gomock.Call.Do func (c *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall) Do(f func(any, *gitlab.SetProjectGoogleChatOptions, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall) DoAndReturn(f func(any, *gitlab.SetProjectGoogleChatOptions, ...gitlab.RequestOptionFunc) (*gitlab.GoogleChatIntegration, *gitlab.Response, error)) *MockIntegrationsServiceInterfaceSetProjectGoogleChatSettingsCall { c.Call = c.Call.DoAndReturn(f) return c } // SetUpGroupHarbor mocks base method. func (m *MockIntegrationsServiceInterface) SetUpGroupHarbor(gid any, opt *gitlab.SetUpHarborOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Integration, *gitlab.Response, error) { m.ctrl.T.Helper() Loading