Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
dd77b15a
Commit
dd77b15a
authored
Apr 18, 2019
by
Álvaro Durán Tovar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ApprovalBeforeMerge attribute
parent
ad56ba69
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
merge_request_test.go
merge_request_test.go
+61
-0
merge_requests.go
merge_requests.go
+1
-0
No files found.
merge_request_test.go
0 → 100644
View file @
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"
)
}
}
merge_requests.go
View file @
dd77b15a
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment