mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-31 12:48:47 +00:00
Update go-github library
This commit is contained in:
128
vendor/github.com/google/go-github/github/pulls_test.go
generated
vendored
128
vendor/github.com/google/go-github/github/pulls_test.go
generated
vendored
@@ -17,11 +17,13 @@ import (
|
||||
)
|
||||
|
||||
func TestPullRequestsService_List(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview}
|
||||
mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
|
||||
testFormValues(t, r, values{
|
||||
"state": "closed",
|
||||
"head": "h",
|
||||
@@ -46,16 +48,21 @@ func TestPullRequestsService_List(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_List_invalidOwner(t *testing.T) {
|
||||
client, _, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
_, _, err := client.PullRequests.List(context.Background(), "%", "r", nil)
|
||||
testURLParseError(t, err)
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Get(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview}
|
||||
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
|
||||
fmt.Fprint(w, `{"number":1}`)
|
||||
})
|
||||
|
||||
@@ -70,9 +77,10 @@ func TestPullRequestsService_Get(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullRequestsService_GetRawDiff(t *testing.T) {
|
||||
setup()
|
||||
func TestPullRequestsService_GetRaw_diff(t *testing.T) {
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
const rawStr = "@@diff content"
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -81,19 +89,20 @@ func TestPullRequestsService_GetRawDiff(t *testing.T) {
|
||||
fmt.Fprint(w, rawStr)
|
||||
})
|
||||
|
||||
ret, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Diff})
|
||||
got, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Diff})
|
||||
if err != nil {
|
||||
t.Fatalf("PullRequests.GetRaw returned error: %v", err)
|
||||
}
|
||||
|
||||
if ret != rawStr {
|
||||
t.Errorf("PullRequests.GetRaw returned %s want %s", ret, rawStr)
|
||||
want := rawStr
|
||||
if got != want {
|
||||
t.Errorf("PullRequests.GetRaw returned %s want %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullRequestsService_GetRawPatch(t *testing.T) {
|
||||
setup()
|
||||
func TestPullRequestsService_GetRaw_patch(t *testing.T) {
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
const rawStr = "@@patch content"
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -102,18 +111,18 @@ func TestPullRequestsService_GetRawPatch(t *testing.T) {
|
||||
fmt.Fprint(w, rawStr)
|
||||
})
|
||||
|
||||
ret, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Patch})
|
||||
got, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Patch})
|
||||
if err != nil {
|
||||
t.Fatalf("PullRequests.GetRaw returned error: %v", err)
|
||||
}
|
||||
|
||||
if ret != rawStr {
|
||||
t.Errorf("PullRequests.GetRaw returned %s want %s", ret, rawStr)
|
||||
want := rawStr
|
||||
if got != want {
|
||||
t.Errorf("PullRequests.GetRaw returned %s want %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullRequestsService_GetRawInvalid(t *testing.T) {
|
||||
setup()
|
||||
func TestPullRequestsService_GetRaw_invalid(t *testing.T) {
|
||||
client, _, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
_, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{100})
|
||||
@@ -125,8 +134,61 @@ func TestPullRequestsService_GetRawInvalid(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Get_links(t *testing.T) {
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
fmt.Fprint(w, `{
|
||||
"number":1,
|
||||
"_links":{
|
||||
"self":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/1347"},
|
||||
"html":{"href":"https://github.com/octocat/Hello-World/pull/1347"},
|
||||
"issue":{"href":"https://api.github.com/repos/octocat/Hello-World/issues/1347"},
|
||||
"comments":{"href":"https://api.github.com/repos/octocat/Hello-World/issues/1347/comments"},
|
||||
"review_comments":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"},
|
||||
"review_comment":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"},
|
||||
"commits":{"href":"https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits"},
|
||||
"statuses":{"href":"https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"}
|
||||
}
|
||||
}`)
|
||||
})
|
||||
|
||||
pull, _, err := client.PullRequests.Get(context.Background(), "o", "r", 1)
|
||||
if err != nil {
|
||||
t.Errorf("PullRequests.Get returned error: %v", err)
|
||||
}
|
||||
|
||||
want := &PullRequest{
|
||||
Number: Int(1),
|
||||
Links: &PRLinks{
|
||||
Self: &PRLink{
|
||||
HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347"),
|
||||
}, HTML: &PRLink{
|
||||
HRef: String("https://github.com/octocat/Hello-World/pull/1347"),
|
||||
}, Issue: &PRLink{
|
||||
HRef: String("https://api.github.com/repos/octocat/Hello-World/issues/1347"),
|
||||
}, Comments: &PRLink{
|
||||
HRef: String("https://api.github.com/repos/octocat/Hello-World/issues/1347/comments"),
|
||||
}, ReviewComments: &PRLink{
|
||||
HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments"),
|
||||
}, ReviewComment: &PRLink{
|
||||
HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number}"),
|
||||
}, Commits: &PRLink{
|
||||
HRef: String("https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits"),
|
||||
}, Statuses: &PRLink{
|
||||
HRef: String("https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e"),
|
||||
},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(pull, want) {
|
||||
t.Errorf("PullRequests.Get returned %+v, want %+v", pull, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Get_headAndBase(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -143,11 +205,11 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) {
|
||||
Number: Int(1),
|
||||
Head: &PullRequestBranch{
|
||||
Ref: String("r2"),
|
||||
Repo: &Repository{ID: Int(2)},
|
||||
Repo: &Repository{ID: Int64(2)},
|
||||
},
|
||||
Base: &PullRequestBranch{
|
||||
Ref: String("r1"),
|
||||
Repo: &Repository{ID: Int(1)},
|
||||
Repo: &Repository{ID: Int64(1)},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(pull, want) {
|
||||
@@ -156,7 +218,7 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Get_urlFields(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -195,12 +257,15 @@ func TestPullRequestsService_Get_urlFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Get_invalidOwner(t *testing.T) {
|
||||
client, _, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
_, _, err := client.PullRequests.Get(context.Background(), "%", "r", 1)
|
||||
testURLParseError(t, err)
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Create(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
input := &NewPullRequest{Title: String("t")}
|
||||
@@ -210,6 +275,7 @@ func TestPullRequestsService_Create(t *testing.T) {
|
||||
json.NewDecoder(r.Body).Decode(v)
|
||||
|
||||
testMethod(t, r, "POST")
|
||||
testHeader(t, r, "Accept", mediaTypeLabelDescriptionSearchPreview)
|
||||
if !reflect.DeepEqual(v, input) {
|
||||
t.Errorf("Request body = %+v, want %+v", v, input)
|
||||
}
|
||||
@@ -229,12 +295,15 @@ func TestPullRequestsService_Create(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Create_invalidOwner(t *testing.T) {
|
||||
client, _, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
_, _, err := client.PullRequests.Create(context.Background(), "%", "r", nil)
|
||||
testURLParseError(t, err)
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Edit(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
tests := []struct {
|
||||
@@ -264,8 +333,10 @@ func TestPullRequestsService_Edit(t *testing.T) {
|
||||
|
||||
for i, tt := range tests {
|
||||
madeRequest := false
|
||||
acceptHeaders := []string{mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview}
|
||||
mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%v", i), func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "PATCH")
|
||||
testHeader(t, r, "Accept", strings.Join(acceptHeaders, ", "))
|
||||
testBody(t, r, tt.wantUpdate+"\n")
|
||||
io.WriteString(w, tt.sendResponse)
|
||||
madeRequest = true
|
||||
@@ -287,12 +358,15 @@ func TestPullRequestsService_Edit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Edit_invalidOwner(t *testing.T) {
|
||||
client, _, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
_, _, err := client.PullRequests.Edit(context.Background(), "%", "r", 1, &PullRequest{})
|
||||
testURLParseError(t, err)
|
||||
}
|
||||
|
||||
func TestPullRequestsService_ListCommits(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1/commits", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -350,7 +424,7 @@ func TestPullRequestsService_ListCommits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_ListFiles(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1/files", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -412,7 +486,7 @@ func TestPullRequestsService_ListFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_IsMerged(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -432,7 +506,7 @@ func TestPullRequestsService_IsMerged(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPullRequestsService_Merge(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -463,7 +537,7 @@ func TestPullRequestsService_Merge(t *testing.T) {
|
||||
|
||||
// Test that different merge options produce expected PUT requests. See issue https://github.com/google/go-github/issues/500.
|
||||
func TestPullRequestsService_Merge_options(t *testing.T) {
|
||||
setup()
|
||||
client, mux, _, teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
tests := []struct {
|
||||
|
||||
Reference in New Issue
Block a user