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

@@ -19,7 +19,7 @@ func TestUser_marshall(t *testing.T) {
u := &User{
Login: String("l"),
ID: Int(1),
ID: Int64(1),
URL: String("u"),
AvatarURL: String("a"),
GravatarID: String("g"),
@@ -57,7 +57,7 @@ func TestUser_marshall(t *testing.T) {
}
func TestUsersService_Get_authenticatedUser(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) {
@@ -70,14 +70,14 @@ func TestUsersService_Get_authenticatedUser(t *testing.T) {
t.Errorf("Users.Get returned error: %v", err)
}
want := &User{ID: Int(1)}
want := &User{ID: Int64(1)}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.Get returned %+v, want %+v", user, want)
}
}
func TestUsersService_Get_specifiedUser(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/users/u", func(w http.ResponseWriter, r *http.Request) {
@@ -90,19 +90,22 @@ func TestUsersService_Get_specifiedUser(t *testing.T) {
t.Errorf("Users.Get returned error: %v", err)
}
want := &User{ID: Int(1)}
want := &User{ID: Int64(1)}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.Get returned %+v, want %+v", user, want)
}
}
func TestUsersService_Get_invalidUser(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
_, _, err := client.Users.Get(context.Background(), "%")
testURLParseError(t, err)
}
func TestUsersService_GetByID(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/user/1", func(w http.ResponseWriter, r *http.Request) {
@@ -115,14 +118,14 @@ func TestUsersService_GetByID(t *testing.T) {
t.Fatalf("Users.GetByID returned error: %v", err)
}
want := &User{ID: Int(1)}
want := &User{ID: Int64(1)}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.GetByID returned %+v, want %+v", user, want)
}
}
func TestUsersService_Edit(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
input := &User{Name: String("n")}
@@ -144,14 +147,37 @@ func TestUsersService_Edit(t *testing.T) {
t.Errorf("Users.Edit returned error: %v", err)
}
want := &User{ID: Int(1)}
want := &User{ID: Int64(1)}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.Edit returned %+v, want %+v", user, want)
}
}
func TestUsersService_GetHovercard(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/users/u/hovercard", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeHovercardPreview)
testFormValues(t, r, values{"subject_type": "repository", "subject_id": "20180408"})
fmt.Fprint(w, `{"contexts": [{"message":"Owns this repository", "octicon": "repo"}]}`)
})
opt := &HovercardOptions{SubjectType: "repository", SubjectID: "20180408"}
hovercard, _, err := client.Users.GetHovercard(context.Background(), "u", opt)
if err != nil {
t.Errorf("Users.GetHovercard returned error: %v", err)
}
want := &Hovercard{Contexts: []*UserContext{{Message: String("Owns this repository"), Octicon: String("repo")}}}
if !reflect.DeepEqual(hovercard, want) {
t.Errorf("Users.GetHovercard returned %+v, want %+v", hovercard, want)
}
}
func TestUsersService_ListAll(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
@@ -166,14 +192,14 @@ func TestUsersService_ListAll(t *testing.T) {
t.Errorf("Users.Get returned error: %v", err)
}
want := []*User{{ID: Int(2)}}
want := []*User{{ID: Int64(2)}}
if !reflect.DeepEqual(users, want) {
t.Errorf("Users.ListAll returned %+v, want %+v", users, want)
}
}
func TestUsersService_ListInvitations(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) {
@@ -187,14 +213,14 @@ func TestUsersService_ListInvitations(t *testing.T) {
t.Errorf("Users.ListInvitations returned error: %v", err)
}
want := []*RepositoryInvitation{{ID: Int(1)}, {ID: Int(2)}}
want := []*RepositoryInvitation{{ID: Int64(1)}, {ID: Int64(2)}}
if !reflect.DeepEqual(got, want) {
t.Errorf("Users.ListInvitations = %+v, want %+v", got, want)
}
}
func TestUsersService_ListInvitations_withOptions(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) {
@@ -212,7 +238,7 @@ func TestUsersService_ListInvitations_withOptions(t *testing.T) {
}
}
func TestUsersService_AcceptInvitation(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) {
@@ -227,7 +253,7 @@ func TestUsersService_AcceptInvitation(t *testing.T) {
}
func TestUsersService_DeclineInvitation(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) {