Unverified Commit 4dea4500 authored by Sander van Harmelen's avatar Sander van Harmelen Committed by GitHub

Merge pull request #611 from hermesdt/add-approvals-before-merge

Add ApprovalsBeforeMerge attribute
parents ad56ba69 dd77b15a
package gitlab
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestListMergeRequestsNullApprovals(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/api/v4/merge_requests", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{"id":1, "title": "some title", "approvals_before_merge": null}]`)
})
mr, _, err := client.MergeRequests.ListMergeRequests(nil)
if err != nil {
t.Errorf("MergeRequests.ListMergeRequests returned error: %v", err)
}
want := []*MergeRequest{{ID: 1, Title: "some title", ApprovalsBeforeMerge: 0}}
if !reflect.DeepEqual(want, mr) {
t.Errorf("MergeRequests.ListMergeRequests returned %+v, want %+v", mr, want)
}
}
func TestListMergeRequests2Approvals(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/api/v4/merge_requests", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{"id":1, "title": "some title", "approvals_before_merge": 2}]`)
})
mr, _, err := client.MergeRequests.ListMergeRequests(nil)
if err != nil {
t.Errorf("MergeRequests.ListMergeRequests returned error: %v", err)
}
want := []*MergeRequest{{ID: 1, Title: "some title", ApprovalsBeforeMerge: 2}}
if !reflect.DeepEqual(want, mr) {
t.Errorf("MergeRequests.ListMergeRequests returned %+v, want %+v", mr, want)
}
}
func TestListMergeRequestsError(t *testing.T) {
_, server, client := setup()
defer teardown(server)
_, _, err := client.MergeRequests.ListMergeRequests(nil)
if err == nil {
t.Errorf("MergeRequests.ListMergeRequests expected to receive error, but returned nil")
}
}
......@@ -118,6 +118,7 @@ type MergeRequest struct {
} `json:"diff_refs"`
DivergedCommitsCount int `json:"diverged_commits_count"`
RebaseInProgress bool `json:"rebase_in_progress"`
ApprovalsBeforeMerge int `json:"approvals_before_merge"`
}
func (m MergeRequest) String() string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment