mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-31 08:48:43 +00:00
Update go-github library
This commit is contained in:
42
vendor/github.com/google/go-github/github/git_blobs_test.go
generated
vendored
42
vendor/github.com/google/go-github/github/git_blobs_test.go
generated
vendored
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user