Update go-github library

This commit is contained in:
Luke Kysow
2018-12-12 09:55:17 -06:00
parent e001353ae9
commit 139f05ab49
170 changed files with 14305 additions and 3086 deletions

View File

@@ -15,7 +15,7 @@ import (
)
func TestRepositoriesService_ListContributorsStats(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/stats/contributors", func(w http.ResponseWriter, r *http.Request) {
@@ -49,12 +49,12 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) {
want := []*ContributorStats{
{
Author: &Contributor{
ID: Int(1),
ID: Int64(1),
},
Total: Int(135),
Weeks: []WeeklyStats{
{
Week: &Timestamp{time.Date(2013, 05, 05, 00, 00, 00, 0, time.UTC).Local()},
Week: &Timestamp{time.Date(2013, time.May, 05, 00, 00, 00, 0, time.UTC).Local()},
Additions: Int(6898),
Deletions: Int(77),
Commits: Int(10),
@@ -69,7 +69,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) {
}
func TestRepositoriesService_ListCommitActivity(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/stats/commit_activity", func(w http.ResponseWriter, r *http.Request) {
@@ -95,7 +95,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) {
{
Days: []int{0, 3, 26, 20, 39, 1, 0},
Total: Int(89),
Week: &Timestamp{time.Date(2012, 05, 06, 05, 00, 00, 0, time.UTC).Local()},
Week: &Timestamp{time.Date(2012, time.May, 06, 05, 00, 00, 0, time.UTC).Local()},
},
}
@@ -105,7 +105,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) {
}
func TestRepositoriesService_ListCodeFrequency(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/stats/code_frequency", func(w http.ResponseWriter, r *http.Request) {
@@ -120,7 +120,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) {
}
want := []*WeeklyStats{{
Week: &Timestamp{time.Date(2011, 04, 17, 00, 00, 00, 0, time.UTC).Local()},
Week: &Timestamp{time.Date(2011, time.April, 17, 00, 00, 00, 0, time.UTC).Local()},
Additions: Int(1124),
Deletions: Int(-435),
}}
@@ -131,7 +131,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) {
}
func TestRepositoriesService_Participation(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/stats/participation", func(w http.ResponseWriter, r *http.Request) {
@@ -181,7 +181,7 @@ func TestRepositoriesService_Participation(t *testing.T) {
}
func TestRepositoriesService_ListPunchCard(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/stats/punch_card", func(w http.ResponseWriter, r *http.Request) {
@@ -209,3 +209,28 @@ func TestRepositoriesService_ListPunchCard(t *testing.T) {
t.Errorf("RepositoriesService.ListPunchCard returned %+v, want %+v", card, want)
}
}
func TestRepositoriesService_AcceptedError(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/stats/contributors", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
// This response indicates the fork will happen asynchronously.
w.WriteHeader(http.StatusAccepted)
fmt.Fprint(w, `{"id":1}`)
})
stats, _, err := client.Repositories.ListContributorsStats(context.Background(), "o", "r")
if err == nil {
t.Errorf("RepositoriesService.AcceptedError should have returned an error")
}
if _, ok := err.(*AcceptedError); !ok {
t.Errorf("RepositoriesService.AcceptedError returned an AcceptedError: %v", err)
}
if stats != nil {
t.Errorf("RepositoriesService.AcceptedError expected stats to be nil: %v", stats)
}
}