forked from plouc/go-gitlab-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge_requests_test.go
84 lines (68 loc) · 2.08 KB
/
merge_requests_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package gogitlab
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestProjectMergeRequests(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/index.json")
mrs, err := gitlab.ProjectMergeRequests("3", nil)
assert.Equal(t, err, nil)
assert.Equal(t, len(mrs), 1)
defer ts.Close()
}
func TestProjectMergeRequest(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
mr, err := gitlab.ProjectMergeRequest("3", "1")
assert.Equal(t, err, nil)
assert.Equal(t, mr.TargetBranch, "master")
assert.Equal(t, mr.MergeStatus, "can_be_merged")
assert.Equal(t, mr.SourceProjectID, 2)
assert.Equal(t, mr.TargetProjectID, 3)
defer ts.Close()
}
func TestProjectMergeRequestCommits(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/commits.json")
commits, err := gitlab.ProjectMergeRequestCommits("3", "1")
assert.Equal(t, err, nil)
assert.Equal(t, len(commits), 2)
defer ts.Close()
}
func TestProjectMergeRequestChanges(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/changes.json")
mr, err := gitlab.ProjectMergeRequestChanges("3", "1")
assert.Equal(t, err, nil)
assert.Equal(t, len(mr.Changes), 1)
defer ts.Close()
}
func TestAddMergeRequest(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
req := AddMergeRequestRequest{
TargetProjectId: 3,
}
_, err := gitlab.AddMergeRequest(&req)
assert.Equal(t, err, nil)
defer ts.Close()
}
func TestEditMergeRequest(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
req := MergeRequest{
ProjectId: 3,
Id: 1,
}
err := gitlab.EditMergeRequest(&req)
assert.Equal(t, err, nil)
defer ts.Close()
}
func TestProjectMergeRequestAccept(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
req := AcceptMergeRequestRequest{}
_, err := gitlab.ProjectMergeRequestAccept("3", "1", &req)
assert.Equal(t, err, nil)
defer ts.Close()
}
func TestProjectMergeRequestCancelMerge(t *testing.T) {
ts, gitlab := Stub("stubs/merge_requests/show.json")
_, err := gitlab.ProjectMergeRequestCancelMerge("3", "1")
assert.Equal(t, err, nil)
defer ts.Close()
}