Loading draft_notes.go +30 −1 Changes for draft_notes.go: 30 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -69,8 +69,19 @@ type ( // PublishAllDraftNotes publishes all draft notes for a merge request that belong to the user. // // GitLab API docs: // https://docs.gitlab.com/api/draft_notes/#publish-a-draft-note // https://docs.gitlab.com/api/draft_notes/#publish-all-pending-draft-notes PublishAllDraftNotes(pid any, mergeRequest int64, options ...RequestOptionFunc) (*Response, error) // PublishAllDraftNotesWithOptions publishes all draft notes for a merge // request that belong to the user, with options. // // Deprecated: PublishAllDraftNotesWithOptions will be removed in version // 4.0, and the `PublishAllDraftNotesOptions` will be moved into the // normal `PublishAllDraftNotes`. // // GitLab API docs: // https://docs.gitlab.com/api/draft_notes/#publish-all-pending-draft-notes PublishAllDraftNotesWithOptions(pid any, mergeRequest int64, opt *PublishAllDraftNotesOptions, options ...RequestOptionFunc) (*Response, error) } // DraftNotesService handles communication with the draft notes related methods Loading Loading @@ -184,10 +195,28 @@ func (s *DraftNotesService) PublishDraftNote(pid any, mergeRequest int64, note i return resp, err } // PublishAllDraftNotesOptions represents the available // PublishAllDraftNotes() options. // // GitLab API docs: // https://docs.gitlab.com/api/draft_notes/#publish-all-pending-draft-notes type PublishAllDraftNotesOptions struct { Note *string `url:"note,omitempty" json:"note,omitempty"` Internal *bool `url:"internal,omitempty" json:"internal,omitempty"` ReviewerState *string `url:"reviewer_state,omitempty" json:"reviewer_state,omitempty"` } func (s *DraftNotesService) PublishAllDraftNotes(pid any, mergeRequest int64, options ...RequestOptionFunc) (*Response, error) { return s.PublishAllDraftNotesWithOptions(pid, mergeRequest, nil, options...) } // Deprecated: use PublishAllDraftNotes instead unless you need "opt", which // will be merged into PublishAllDraftNotes in 4.0 when this is removed. func (s *DraftNotesService) PublishAllDraftNotesWithOptions(pid any, mergeRequest int64, opt *PublishAllDraftNotesOptions, options ...RequestOptionFunc) (*Response, error) { _, resp, err := do[none](s.client, withMethod(http.MethodPost), withPath(routeProjectsIDMergeRequestsIDDraftNotesBulkPublish, ProjectID{pid}, mergeRequest), withAPIOpts(opt), withRequestOpts(options...), ) return resp, err Loading draft_notes_test.go +23 −0 Changes for draft_notes_test.go: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -192,8 +192,31 @@ func TestPublishAllDraftNotes(t *testing.T) { mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/merge_requests/4329/draft_notes/bulk_publish", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) // Pin the wire shape of the nil-opt delegation through PublishAllDraftNotesWithOptions: // a literal JSON null body, which decodes to a nil map (an empty body would error, {} yields a non-nil map). testBodyJSON(t, r, map[string]any(nil)) }) _, err := client.DraftNotes.PublishAllDraftNotes("1", 4329) require.NoError(t, err) } func TestPublishAllDraftNotesWithOptions(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/merge_requests/4329/draft_notes/bulk_publish", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testBodyJSON(t, r, map[string]any{ "note": "Overall looks good.", "internal": true, "reviewer_state": "requested_changes", }) }) _, err := client.DraftNotes.PublishAllDraftNotesWithOptions("1", 4329, &PublishAllDraftNotesOptions{ Note: new("Overall looks good."), Internal: new(true), ReviewerState: new("requested_changes"), }) require.NoError(t, err) } testing/draft_notes_mock.go +44 −0 Changes for testing/draft_notes_mock.go: 44 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -262,6 +262,50 @@ func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesCall) DoAndReturn(f f return c } // PublishAllDraftNotesWithOptions mocks base method. func (m *MockDraftNotesServiceInterface) PublishAllDraftNotesWithOptions(pid any, mergeRequest int64, opt *gitlab.PublishAllDraftNotesOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid, mergeRequest, opt} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "PublishAllDraftNotesWithOptions", varargs...) ret0, _ := ret[0].(*gitlab.Response) ret1, _ := ret[1].(error) return ret0, ret1 } // PublishAllDraftNotesWithOptions indicates an expected call of PublishAllDraftNotesWithOptions. func (mr *MockDraftNotesServiceInterfaceMockRecorder) PublishAllDraftNotesWithOptions(pid, mergeRequest, opt any, options ...any) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid, mergeRequest, opt}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishAllDraftNotesWithOptions", reflect.TypeOf((*MockDraftNotesServiceInterface)(nil).PublishAllDraftNotesWithOptions), varargs...) return &MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall{Call: call} } // MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall wrap *gomock.Call type MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall) Return(arg0 *gitlab.Response, arg1 error) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { c.Call = c.Call.Return(arg0, arg1) return c } // Do rewrite *gomock.Call.Do func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall) Do(f func(any, int64, *gitlab.PublishAllDraftNotesOptions, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall) DoAndReturn(f func(any, int64, *gitlab.PublishAllDraftNotesOptions, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { c.Call = c.Call.DoAndReturn(f) return c } // PublishDraftNote mocks base method. func (m *MockDraftNotesServiceInterface) PublishDraftNote(pid any, mergeRequest, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) { m.ctrl.T.Helper() Loading Loading
draft_notes.go +30 −1 Changes for draft_notes.go: 30 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -69,8 +69,19 @@ type ( // PublishAllDraftNotes publishes all draft notes for a merge request that belong to the user. // // GitLab API docs: // https://docs.gitlab.com/api/draft_notes/#publish-a-draft-note // https://docs.gitlab.com/api/draft_notes/#publish-all-pending-draft-notes PublishAllDraftNotes(pid any, mergeRequest int64, options ...RequestOptionFunc) (*Response, error) // PublishAllDraftNotesWithOptions publishes all draft notes for a merge // request that belong to the user, with options. // // Deprecated: PublishAllDraftNotesWithOptions will be removed in version // 4.0, and the `PublishAllDraftNotesOptions` will be moved into the // normal `PublishAllDraftNotes`. // // GitLab API docs: // https://docs.gitlab.com/api/draft_notes/#publish-all-pending-draft-notes PublishAllDraftNotesWithOptions(pid any, mergeRequest int64, opt *PublishAllDraftNotesOptions, options ...RequestOptionFunc) (*Response, error) } // DraftNotesService handles communication with the draft notes related methods Loading Loading @@ -184,10 +195,28 @@ func (s *DraftNotesService) PublishDraftNote(pid any, mergeRequest int64, note i return resp, err } // PublishAllDraftNotesOptions represents the available // PublishAllDraftNotes() options. // // GitLab API docs: // https://docs.gitlab.com/api/draft_notes/#publish-all-pending-draft-notes type PublishAllDraftNotesOptions struct { Note *string `url:"note,omitempty" json:"note,omitempty"` Internal *bool `url:"internal,omitempty" json:"internal,omitempty"` ReviewerState *string `url:"reviewer_state,omitempty" json:"reviewer_state,omitempty"` } func (s *DraftNotesService) PublishAllDraftNotes(pid any, mergeRequest int64, options ...RequestOptionFunc) (*Response, error) { return s.PublishAllDraftNotesWithOptions(pid, mergeRequest, nil, options...) } // Deprecated: use PublishAllDraftNotes instead unless you need "opt", which // will be merged into PublishAllDraftNotes in 4.0 when this is removed. func (s *DraftNotesService) PublishAllDraftNotesWithOptions(pid any, mergeRequest int64, opt *PublishAllDraftNotesOptions, options ...RequestOptionFunc) (*Response, error) { _, resp, err := do[none](s.client, withMethod(http.MethodPost), withPath(routeProjectsIDMergeRequestsIDDraftNotesBulkPublish, ProjectID{pid}, mergeRequest), withAPIOpts(opt), withRequestOpts(options...), ) return resp, err Loading
draft_notes_test.go +23 −0 Changes for draft_notes_test.go: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -192,8 +192,31 @@ func TestPublishAllDraftNotes(t *testing.T) { mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/merge_requests/4329/draft_notes/bulk_publish", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) // Pin the wire shape of the nil-opt delegation through PublishAllDraftNotesWithOptions: // a literal JSON null body, which decodes to a nil map (an empty body would error, {} yields a non-nil map). testBodyJSON(t, r, map[string]any(nil)) }) _, err := client.DraftNotes.PublishAllDraftNotes("1", 4329) require.NoError(t, err) } func TestPublishAllDraftNotesWithOptions(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/merge_requests/4329/draft_notes/bulk_publish", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testBodyJSON(t, r, map[string]any{ "note": "Overall looks good.", "internal": true, "reviewer_state": "requested_changes", }) }) _, err := client.DraftNotes.PublishAllDraftNotesWithOptions("1", 4329, &PublishAllDraftNotesOptions{ Note: new("Overall looks good."), Internal: new(true), ReviewerState: new("requested_changes"), }) require.NoError(t, err) }
testing/draft_notes_mock.go +44 −0 Changes for testing/draft_notes_mock.go: 44 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -262,6 +262,50 @@ func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesCall) DoAndReturn(f f return c } // PublishAllDraftNotesWithOptions mocks base method. func (m *MockDraftNotesServiceInterface) PublishAllDraftNotesWithOptions(pid any, mergeRequest int64, opt *gitlab.PublishAllDraftNotesOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) { m.ctrl.T.Helper() varargs := []any{pid, mergeRequest, opt} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "PublishAllDraftNotesWithOptions", varargs...) ret0, _ := ret[0].(*gitlab.Response) ret1, _ := ret[1].(error) return ret0, ret1 } // PublishAllDraftNotesWithOptions indicates an expected call of PublishAllDraftNotesWithOptions. func (mr *MockDraftNotesServiceInterfaceMockRecorder) PublishAllDraftNotesWithOptions(pid, mergeRequest, opt any, options ...any) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { mr.mock.ctrl.T.Helper() varargs := append([]any{pid, mergeRequest, opt}, options...) call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishAllDraftNotesWithOptions", reflect.TypeOf((*MockDraftNotesServiceInterface)(nil).PublishAllDraftNotesWithOptions), varargs...) return &MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall{Call: call} } // MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall wrap *gomock.Call type MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall struct { *gomock.Call } // Return rewrite *gomock.Call.Return func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall) Return(arg0 *gitlab.Response, arg1 error) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { c.Call = c.Call.Return(arg0, arg1) return c } // Do rewrite *gomock.Call.Do func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall) Do(f func(any, int64, *gitlab.PublishAllDraftNotesOptions, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { c.Call = c.Call.Do(f) return c } // DoAndReturn rewrite *gomock.Call.DoAndReturn func (c *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall) DoAndReturn(f func(any, int64, *gitlab.PublishAllDraftNotesOptions, ...gitlab.RequestOptionFunc) (*gitlab.Response, error)) *MockDraftNotesServiceInterfacePublishAllDraftNotesWithOptionsCall { c.Call = c.Call.DoAndReturn(f) return c } // PublishDraftNote mocks base method. func (m *MockDraftNotesServiceInterface) PublishDraftNote(pid any, mergeRequest, note int64, options ...gitlab.RequestOptionFunc) (*gitlab.Response, error) { m.ctrl.T.Helper() Loading