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

@@ -10,12 +10,13 @@ import (
"fmt"
"net/http"
"reflect"
"strings"
"testing"
"time"
)
func TestRepositoriesService_ListCommits(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
// given
@@ -52,7 +53,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) {
}
func TestRepositoriesService_GetCommit(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) {
@@ -126,8 +127,65 @@ func TestRepositoriesService_GetCommit(t *testing.T) {
}
}
func TestRepositoriesService_GetCommitRaw_diff(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
const rawStr = "@@diff content"
mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeV3Diff)
fmt.Fprint(w, rawStr)
})
got, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{Type: Diff})
if err != nil {
t.Fatalf("Repositories.GetCommitRaw returned error: %v", err)
}
want := rawStr
if got != want {
t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want)
}
}
func TestRepositoriesService_GetCommitRaw_patch(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
const rawStr = "@@patch content"
mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeV3Patch)
fmt.Fprint(w, rawStr)
})
got, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{Type: Patch})
if err != nil {
t.Fatalf("Repositories.GetCommitRaw returned error: %v", err)
}
want := rawStr
if got != want {
t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want)
}
}
func TestRepositoriesService_GetCommitRaw_invalid(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
_, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{100})
if err == nil {
t.Fatal("Repositories.GetCommitRaw should return error")
}
if !strings.Contains(err.Error(), "unsupported raw type") {
t.Error("Repositories.GetCommitRaw should return unsupported raw type error")
}
}
func TestRepositoriesService_GetCommitSHA1(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
const sha1 = "01234abcde"
@@ -168,7 +226,7 @@ func TestRepositoriesService_GetCommitSHA1(t *testing.T) {
}
func TestRepositoriesService_CompareCommits(t *testing.T) {
setup()
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/compare/b...h", func(w http.ResponseWriter, r *http.Request) {