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

@@ -6,6 +6,7 @@
package github
import (
"bytes"
"context"
"encoding/json"
"fmt"
@@ -15,13 +16,12 @@ import (
)
func TestGitService_GetBlob(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/git/blobs/s", func(w http.ResponseWriter, r *http.Request) {
if m := "GET"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
testMethod(t, r, "GET")
fmt.Fprint(w, `{
"sha": "s",
"content": "blob content"
@@ -44,12 +44,37 @@ func TestGitService_GetBlob(t *testing.T) {
}
func TestGitService_GetBlob_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
_, _, err := client.Git.GetBlob(context.Background(), "%", "%", "%")
testURLParseError(t, err)
}
func TestGitService_GetBlobRaw(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/git/blobs/s", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", "application/vnd.github.v3.raw")
fmt.Fprint(w, `raw contents here`)
})
blob, _, err := client.Git.GetBlobRaw(context.Background(), "o", "r", "s")
if err != nil {
t.Errorf("Git.GetBlobRaw returned error: %v", err)
}
want := []byte("raw contents here")
if !bytes.Equal(blob, want) {
t.Errorf("GetBlobRaw returned %q, want %q", blob, want)
}
}
func TestGitService_CreateBlob(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
input := &Blob{
@@ -63,9 +88,7 @@ func TestGitService_CreateBlob(t *testing.T) {
v := new(Blob)
json.NewDecoder(r.Body).Decode(v)
if m := "POST"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
testMethod(t, r, "POST")
want := input
if !reflect.DeepEqual(v, want) {
@@ -93,6 +116,9 @@ func TestGitService_CreateBlob(t *testing.T) {
}
func TestGitService_CreateBlob_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
_, _, err := client.Git.CreateBlob(context.Background(), "%", "%", &Blob{})
testURLParseError(t, err)
}