diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-06-13 20:23:21 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-06-13 20:23:21 +0200 |
| commit | b41e96b421acda1761e9ba2ee17da16efad436cd (patch) | |
| tree | b6200bf1c3665161b6d76453bb56f7bd5ce32f42 /vendor/google.golang.org/api/googleapi | |
| parent | f58147fb5ea43427d38c2a4437f35647138fbf9d (diff) | |
vendor: switch from dep to godep
dep tool vendored too much code (100MB) including tests and unused packages.
godep vendored significantly less (12MB) without tests and unused packages.
The main advantage is that pre-Go1.9 toolchain does not run tests
of all vendor packages now.
Diffstat (limited to 'vendor/google.golang.org/api/googleapi')
4 files changed, 1 insertions, 640 deletions
diff --git a/vendor/google.golang.org/api/googleapi/googleapi.go b/vendor/google.golang.org/api/googleapi/googleapi.go index f6e15be35..bdb11c4ec 100644 --- a/vendor/google.golang.org/api/googleapi/googleapi.go +++ b/vendor/google.golang.org/api/googleapi/googleapi.go @@ -4,7 +4,7 @@ // Package googleapi contains the common code shared by all Google API // libraries. -package googleapi // import "google.golang.org/api/googleapi" +package googleapi import ( "bytes" diff --git a/vendor/google.golang.org/api/googleapi/googleapi_test.go b/vendor/google.golang.org/api/googleapi/googleapi_test.go deleted file mode 100644 index dd39a5cdc..000000000 --- a/vendor/google.golang.org/api/googleapi/googleapi_test.go +++ /dev/null @@ -1,291 +0,0 @@ -// Copyright 2011 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package googleapi - -import ( - "encoding/json" - "io/ioutil" - "net/http" - "net/url" - "reflect" - "strings" - "testing" -) - -type ExpandTest struct { - in string - expansions map[string]string - want string -} - -var expandTests = []ExpandTest{ - // no expansions - { - "http://www.golang.org/", - map[string]string{}, - "http://www.golang.org/", - }, - // one expansion, no escaping - { - "http://www.golang.org/{bucket}/delete", - map[string]string{ - "bucket": "red", - }, - "http://www.golang.org/red/delete", - }, - // one expansion, with hex escapes - { - "http://www.golang.org/{bucket}/delete", - map[string]string{ - "bucket": "red/blue", - }, - "http://www.golang.org/red%2Fblue/delete", - }, - // one expansion, with space - { - "http://www.golang.org/{bucket}/delete", - map[string]string{ - "bucket": "red or blue", - }, - "http://www.golang.org/red%20or%20blue/delete", - }, - // expansion not found - { - "http://www.golang.org/{object}/delete", - map[string]string{ - "bucket": "red or blue", - }, - "http://www.golang.org//delete", - }, - // multiple expansions - { - "http://www.golang.org/{one}/{two}/{three}/get", - map[string]string{ - "one": "ONE", - "two": "TWO", - "three": "THREE", - }, - "http://www.golang.org/ONE/TWO/THREE/get", - }, - // utf-8 characters - { - "http://www.golang.org/{bucket}/get", - map[string]string{ - "bucket": "£100", - }, - "http://www.golang.org/%C2%A3100/get", - }, - // punctuations - { - "http://www.golang.org/{bucket}/get", - map[string]string{ - "bucket": `/\@:,.`, - }, - "http://www.golang.org/%2F%5C%40%3A%2C./get", - }, - // mis-matched brackets - { - "http://www.golang.org/{bucket/get", - map[string]string{ - "bucket": "red", - }, - "http://www.golang.org/%7Bbucket/get", - }, - // "+" prefix for suppressing escape - // See also: http://tools.ietf.org/html/rfc6570#section-3.2.3 - { - "http://www.golang.org/{+topic}", - map[string]string{ - "topic": "/topics/myproject/mytopic", - }, - // The double slashes here look weird, but it's intentional - "http://www.golang.org//topics/myproject/mytopic", - }, -} - -func TestExpand(t *testing.T) { - for i, test := range expandTests { - u := url.URL{ - Path: test.in, - } - Expand(&u, test.expansions) - got := u.EscapedPath() - if got != test.want { - t.Errorf("got %q expected %q in test %d", got, test.want, i+1) - } - } -} - -type CheckResponseTest struct { - in *http.Response - bodyText string - want error - errText string -} - -var checkResponseTests = []CheckResponseTest{ - { - &http.Response{ - StatusCode: http.StatusOK, - }, - "", - nil, - "", - }, - { - &http.Response{ - StatusCode: http.StatusInternalServerError, - }, - `{"error":{}}`, - &Error{ - Code: http.StatusInternalServerError, - Body: `{"error":{}}`, - }, - `googleapi: got HTTP response code 500 with body: {"error":{}}`, - }, - { - &http.Response{ - StatusCode: http.StatusNotFound, - }, - `{"error":{"message":"Error message for StatusNotFound."}}`, - &Error{ - Code: http.StatusNotFound, - Message: "Error message for StatusNotFound.", - Body: `{"error":{"message":"Error message for StatusNotFound."}}`, - }, - "googleapi: Error 404: Error message for StatusNotFound.", - }, - { - &http.Response{ - StatusCode: http.StatusBadRequest, - }, - `{"error":"invalid_token","error_description":"Invalid Value"}`, - &Error{ - Code: http.StatusBadRequest, - Body: `{"error":"invalid_token","error_description":"Invalid Value"}`, - }, - `googleapi: got HTTP response code 400 with body: {"error":"invalid_token","error_description":"Invalid Value"}`, - }, - { - &http.Response{ - StatusCode: http.StatusBadRequest, - }, - `{"error":{"errors":[{"domain":"usageLimits","reason":"keyInvalid","message":"Bad Request"}],"code":400,"message":"Bad Request"}}`, - &Error{ - Code: http.StatusBadRequest, - Errors: []ErrorItem{ - { - Reason: "keyInvalid", - Message: "Bad Request", - }, - }, - Body: `{"error":{"errors":[{"domain":"usageLimits","reason":"keyInvalid","message":"Bad Request"}],"code":400,"message":"Bad Request"}}`, - Message: "Bad Request", - }, - "googleapi: Error 400: Bad Request, keyInvalid", - }, -} - -func TestCheckResponse(t *testing.T) { - for _, test := range checkResponseTests { - res := test.in - if test.bodyText != "" { - res.Body = ioutil.NopCloser(strings.NewReader(test.bodyText)) - } - g := CheckResponse(res) - if !reflect.DeepEqual(g, test.want) { - t.Errorf("CheckResponse: got %v, want %v", g, test.want) - gotJson, err := json.Marshal(g) - if err != nil { - t.Error(err) - } - wantJson, err := json.Marshal(test.want) - if err != nil { - t.Error(err) - } - t.Errorf("json(got): %q\njson(want): %q", string(gotJson), string(wantJson)) - } - if g != nil && g.Error() != test.errText { - t.Errorf("CheckResponse: unexpected error message.\nGot: %q\nwant: %q", g, test.errText) - } - } -} - -type VariantPoint struct { - Type string - Coordinates []float64 -} - -type VariantTest struct { - in map[string]interface{} - result bool - want VariantPoint -} - -var coords = []interface{}{1.0, 2.0} - -var variantTests = []VariantTest{ - { - in: map[string]interface{}{ - "type": "Point", - "coordinates": coords, - }, - result: true, - want: VariantPoint{ - Type: "Point", - Coordinates: []float64{1.0, 2.0}, - }, - }, - { - in: map[string]interface{}{ - "type": "Point", - "bogus": coords, - }, - result: true, - want: VariantPoint{ - Type: "Point", - }, - }, -} - -func TestVariantType(t *testing.T) { - for _, test := range variantTests { - if g := VariantType(test.in); g != test.want.Type { - t.Errorf("VariantType(%v): got %v, want %v", test.in, g, test.want.Type) - } - } -} - -func TestConvertVariant(t *testing.T) { - for _, test := range variantTests { - g := VariantPoint{} - r := ConvertVariant(test.in, &g) - if r != test.result { - t.Errorf("ConvertVariant(%v): got %v, want %v", test.in, r, test.result) - } - if !reflect.DeepEqual(g, test.want) { - t.Errorf("ConvertVariant(%v): got %v, want %v", test.in, g, test.want) - } - } -} - -func TestRoundChunkSize(t *testing.T) { - type testCase struct { - in int - want int - } - for _, tc := range []testCase{ - {0, 0}, - {256*1024 - 1, 256 * 1024}, - {256 * 1024, 256 * 1024}, - {256*1024 + 1, 2 * 256 * 1024}, - } { - mo := &MediaOptions{} - ChunkSize(tc.in).setOptions(mo) - if got := mo.ChunkSize; got != tc.want { - t.Errorf("rounding chunk size: got: %v; want %v", got, tc.want) - } - } -} diff --git a/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates_test.go b/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates_test.go deleted file mode 100644 index a60c4efe3..000000000 --- a/vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates_test.go +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uritemplates - -import ( - "fmt" - "log" - "net/url" - "testing" -) - -func ExampleExpand() { - values := map[string]string{ - "user": "golang", - "repo": "go", - } - expanded, _, err := Expand("https://api.github.com/repos{/user,repo}", values) - if err != nil { - log.Fatalf("Error expanding template: %v", err) - } - fmt.Println(expanded) - // Output: - // https://api.github.com/repos/golang/go -} - -func TestExpand(t *testing.T) { - testCases := []struct { - tmpl string - values map[string]string - want string - }{ - // These examples come from the RFC: - // http://tools.ietf.org/html/rfc6570 - { - tmpl: "http://www.example.com/foo{?query,number}", - values: map[string]string{"query": "mycelium", "number": "100"}, - want: "http://www.example.com/foo?query=mycelium&number=100", - }, - { - tmpl: "http://www.example.com/foo{?query,number}", - values: map[string]string{"query": "mycelium"}, - want: "http://www.example.com/foo?query=mycelium", - }, - { - tmpl: "http://www.example.com/foo{?query,number}", - values: map[string]string{}, - want: "http://www.example.com/foo", - }, - } - - for _, tt := range testCases { - exp, _, err := Expand(tt.tmpl, tt.values) - if err != nil { - t.Errorf("Expand(%q, %v) error: %v", tt.tmpl, tt.values, err) - continue - } - if exp != tt.want { - t.Errorf("Expand(%q, %v)\ngot %q\nwant %q", tt.tmpl, tt.values, exp, tt.want) - } - } -} - -func TestExpandRFCLevels(t *testing.T) { - values := map[string]string{ - "dub": "me/too", - "hello": "Hello World!", - "half": "50%", - "var": "value", - "who": "fred", - "base": "http://example.com/home/", - "path": "/foo/bar", - "semi": ";", - "v": "6", - "x": "1024", - "y": "768", - "empty": "", - // undef not mapped. - } - testCases := []struct { - tmpl, want string - }{ - // These examples come from the RFC levels specification. - // http://tools.ietf.org/html/rfc6570 - // Level 1 examples. - {tmpl: "{var}", want: "value"}, - {tmpl: "{hello}", want: "Hello%20World%21"}, - - // Level 2 examples. - {tmpl: "{+var}", want: "value"}, - {tmpl: "{+hello}", want: "Hello%20World!"}, - {tmpl: "{+path}/here", want: "/foo/bar/here"}, - {tmpl: "here?ref={+path}", want: "here?ref=/foo/bar"}, - {tmpl: "X{#var}", want: "X#value"}, - {tmpl: "X{#hello}", want: "X#Hello%20World!"}, - - // Level 3 examples. - {tmpl: "map?{x,y}", want: "map?1024,768"}, - {tmpl: "{x,hello,y}", want: "1024,Hello%20World%21,768"}, - {tmpl: "{+x,hello,y}", want: "1024,Hello%20World!,768"}, - {tmpl: "{+path,x}/here", want: "/foo/bar,1024/here"}, - {tmpl: "{#x,hello,y}", want: "#1024,Hello%20World!,768"}, - {tmpl: "{#path,x}/here", want: "#/foo/bar,1024/here"}, - {tmpl: "X{.var}", want: "X.value"}, - {tmpl: "X{.x,y}", want: "X.1024.768"}, - {tmpl: "{/var}", want: "/value"}, - {tmpl: "{/var,x}/here", want: "/value/1024/here"}, - {tmpl: "{;x,y}", want: ";x=1024;y=768"}, - {tmpl: "{;x,y,empty}", want: ";x=1024;y=768;empty"}, - {tmpl: "{?x,y}", want: "?x=1024&y=768"}, - {tmpl: "{?x,y,empty}", want: "?x=1024&y=768&empty="}, - {tmpl: "?fixed=yes{&x}", want: "?fixed=yes&x=1024"}, - {tmpl: "{&x,y,empty}", want: "&x=1024&y=768&empty="}, - - {tmpl: "{var:3}", want: "val"}, - {tmpl: "{var:30}", want: "value"}, - {tmpl: "{+path:6}/here", want: "/foo/b/here"}, - {tmpl: "{#path:6}/here", want: "#/foo/b/here"}, - {tmpl: "X{.var:3}", want: "X.val"}, - {tmpl: "{/var:1,var}", want: "/v/value"}, - {tmpl: "{;hello:5}", want: ";hello=Hello"}, - {tmpl: "{?var:3}", want: "?var=val"}, - {tmpl: "{&var:3}", want: "&var=val"}, - - // 2.4.1 Prefix values. - {tmpl: "{var}", want: "value"}, - {tmpl: "{var:20}", want: "value"}, - {tmpl: "{var:3}", want: "val"}, - {tmpl: "{semi}", want: "%3B"}, - {tmpl: "{semi:2}", want: "%3B"}, - // 3.2.2. Simple String Expansion: {var} - {tmpl: "{var}", want: "value"}, - {tmpl: "{hello}", want: "Hello%20World%21"}, - {tmpl: "{half}", want: "50%25"}, - {tmpl: "O{empty}X", want: "OX"}, - {tmpl: "O{undef}X", want: "OX"}, - {tmpl: "{x,y}", want: "1024,768"}, - {tmpl: "{x,hello,y}", want: "1024,Hello%20World%21,768"}, - {tmpl: "?{x,empty}", want: "?1024,"}, - {tmpl: "?{x,undef}", want: "?1024"}, - {tmpl: "?{undef,y}", want: "?768"}, - {tmpl: "{var:3}", want: "val"}, - {tmpl: "{var:30}", want: "value"}, - // 3.2.3. Reserved Expansion: {+var} - {tmpl: "{+var}", want: "value"}, - {tmpl: "{+hello}", want: "Hello%20World!"}, - {tmpl: "{+half}", want: "50%25"}, - {tmpl: "{base}index", want: "http%3A%2F%2Fexample.com%2Fhome%2Findex"}, - {tmpl: "{+base}index", want: "http://example.com/home/index"}, - {tmpl: "O{+empty}X", want: "OX"}, - {tmpl: "O{+undef}X", want: "OX"}, - {tmpl: "{+path}/here", want: "/foo/bar/here"}, - {tmpl: "here?ref={+path}", want: "here?ref=/foo/bar"}, - {tmpl: "up{+path}{var}/here", want: "up/foo/barvalue/here"}, - {tmpl: "{+x,hello,y}", want: "1024,Hello%20World!,768"}, - {tmpl: "{+path,x}/here", want: "/foo/bar,1024/here"}, - {tmpl: "{+path:6}/here", want: "/foo/b/here"}, - // 3.2.4. Fragment Expansion: {#var} - {tmpl: "{#var}", want: "#value"}, - {tmpl: "{#hello}", want: "#Hello%20World!"}, - {tmpl: "{#half}", want: "#50%25"}, - {tmpl: "foo{#empty}", want: "foo#"}, - {tmpl: "foo{#undef}", want: "foo"}, - {tmpl: "{#x,hello,y}", want: "#1024,Hello%20World!,768"}, - {tmpl: "{#path,x}/here", want: "#/foo/bar,1024/here"}, - {tmpl: "{#path:6}/here", want: "#/foo/b/here"}, - // 3.2.5. Label Expansion with Dot-Prefix: {.var} - {tmpl: "{.who}", want: ".fred"}, - {tmpl: "{.who,who}", want: ".fred.fred"}, - {tmpl: "{.half,who}", want: ".50%25.fred"}, - {tmpl: "X{.var}", want: "X.value"}, - {tmpl: "X{.empty}", want: "X."}, - {tmpl: "X{.undef}", want: "X"}, - {tmpl: "X{.var:3}", want: "X.val"}, - // 3.2.6. Path Segment Expansion: {/var} - {tmpl: "{/who}", want: "/fred"}, - {tmpl: "{/who,who}", want: "/fred/fred"}, - {tmpl: "{/half,who}", want: "/50%25/fred"}, - {tmpl: "{/who,dub}", want: "/fred/me%2Ftoo"}, - {tmpl: "{/var}", want: "/value"}, - {tmpl: "{/var,empty}", want: "/value/"}, - {tmpl: "{/var,undef}", want: "/value"}, - {tmpl: "{/var,x}/here", want: "/value/1024/here"}, - {tmpl: "{/var:1,var}", want: "/v/value"}, - // 3.2.7. Path-Style Parameter Expansion: {;var} - {tmpl: "{;who}", want: ";who=fred"}, - {tmpl: "{;half}", want: ";half=50%25"}, - {tmpl: "{;empty}", want: ";empty"}, - {tmpl: "{;v,empty,who}", want: ";v=6;empty;who=fred"}, - {tmpl: "{;v,bar,who}", want: ";v=6;who=fred"}, - {tmpl: "{;x,y}", want: ";x=1024;y=768"}, - {tmpl: "{;x,y,empty}", want: ";x=1024;y=768;empty"}, - {tmpl: "{;x,y,undef}", want: ";x=1024;y=768"}, - {tmpl: "{;hello:5}", want: ";hello=Hello"}, - // 3.2.8. Form-Style Query Expansion: {?var} - {tmpl: "{?who}", want: "?who=fred"}, - {tmpl: "{?half}", want: "?half=50%25"}, - {tmpl: "{?x,y}", want: "?x=1024&y=768"}, - {tmpl: "{?x,y,empty}", want: "?x=1024&y=768&empty="}, - {tmpl: "{?x,y,undef}", want: "?x=1024&y=768"}, - {tmpl: "{?var:3}", want: "?var=val"}, - // 3.2.9. Form-Style Query Continuation: {&var} - {tmpl: "{&who}", want: "&who=fred"}, - {tmpl: "{&half}", want: "&half=50%25"}, - {tmpl: "?fixed=yes{&x}", want: "?fixed=yes&x=1024"}, - {tmpl: "{&x,y,empty}", want: "&x=1024&y=768&empty="}, - {tmpl: "{&x,y,undef}", want: "&x=1024&y=768"}, - {tmpl: "{&var:3}", want: "&var=val"}, - } - for _, tt := range testCases { - esc, unesc, err := Expand(tt.tmpl, values) - if err != nil { - t.Errorf("Expand(%q) error: %v", tt.tmpl, err) - continue - } - if esc != tt.want { - t.Errorf("Expand(%q)\ngot %q\nwant %q", tt.tmpl, esc, tt.want) - } - // Check that the escaped form is equivalent to unescaped. - urlUnesc, err := url.QueryUnescape(esc) - if err != nil { - t.Errorf("Expand(%q) gave invalid escaping %q: %v", tt.tmpl, esc, err) - continue - } - if urlUnesc != unesc { - t.Errorf("Expand(%q) gave inconsistent escaped/unescaped\nunescaped %q\nescaped %q\nwhich is %q", tt.tmpl, unesc, esc, urlUnesc) - } - } -} - -func TestExpandUnescaped(t *testing.T) { - testCases := []struct { - tmpl, wantEsc, wantUnesc string - values map[string]string - }{ - { - tmpl: "/foo/{bucket}/bar", - values: map[string]string{ - "bucket": "simple", - }, - wantEsc: "/foo/simple/bar", - wantUnesc: "/foo/simple/bar", - }, - { - tmpl: "/foo/{bucket}/bar", - values: map[string]string{ - "bucket": "path/with/slash", - }, - wantEsc: "/foo/path%2Fwith%2Fslash/bar", - wantUnesc: "/foo/path/with/slash/bar", - }, - { - tmpl: "/foo/{+bucket}/bar", - values: map[string]string{ - "bucket": "path/with/slash", - }, - wantEsc: "/foo/path/with/slash/bar", - wantUnesc: "/foo/path/with/slash/bar", - }, - { - tmpl: "/foo/{bucket}/bar", - values: map[string]string{ - "bucket": "double%2Fescaped", - }, - wantEsc: "/foo/double%252Fescaped/bar", - wantUnesc: "/foo/double%2Fescaped/bar", - }, - } - for _, tt := range testCases { - esc, unesc, err := Expand(tt.tmpl, tt.values) - if err != nil { - t.Errorf("Expand(%q) error: %v", tt.tmpl, err) - continue - } - if esc != tt.wantEsc || unesc != tt.wantUnesc { - t.Errorf("Expand(%q)\ngot esc=%q, unesc=%q\nwant esc=%q, unesc=%q", tt.tmpl, esc, unesc, tt.wantEsc, tt.wantUnesc) - } - } -} diff --git a/vendor/google.golang.org/api/googleapi/types_test.go b/vendor/google.golang.org/api/googleapi/types_test.go deleted file mode 100644 index da386471f..000000000 --- a/vendor/google.golang.org/api/googleapi/types_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2013 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package googleapi - -import ( - "bytes" - "encoding/json" - "reflect" - "testing" -) - -func TestTypes(t *testing.T) { - type T struct { - I32 Int32s - I64 Int64s - U32 Uint32s - U64 Uint64s - F64 Float64s - } - v := &T{ - I32: Int32s{-1, 2, 3}, - I64: Int64s{-1, 2, 1 << 33}, - U32: Uint32s{1, 2}, - U64: Uint64s{1, 2, 1 << 33}, - F64: Float64s{1.5, 3.33}, - } - got, err := json.Marshal(v) - if err != nil { - t.Fatal(err) - } - want := `{"I32":["-1","2","3"],"I64":["-1","2","8589934592"],"U32":["1","2"],"U64":["1","2","8589934592"],"F64":["1.5","3.33"]}` - if string(got) != want { - t.Fatalf("Marshal mismatch.\n got: %s\nwant: %s\n", got, want) - } - - v2 := new(T) - if err := json.Unmarshal(got, v2); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if !reflect.DeepEqual(v, v2) { - t.Fatalf("Unmarshal didn't produce same results.\n got: %#v\nwant: %#v\n", v, v2) - } -} - -func TestRawMessageMarshal(t *testing.T) { - // https://golang.org/issue/14493 - const want = "{}" - b, err := json.Marshal(RawMessage(want)) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - if !bytes.Equal(b, []byte(want)) { - t.Errorf("Marshal(RawMessage(%q)) = %q; want %q", want, b, want) - } -} - -func TestRawMessageUnmarshal(t *testing.T) { - const want = "{}" - var m RawMessage - if err := json.Unmarshal([]byte(want), &m); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if !bytes.Equal([]byte(m), []byte(want)) { - t.Errorf("Unmarshal([]byte(%q), &m); m = %q; want %q", want, string(m), want) - } -} |
