1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-01 16:13:35 +00:00

vendor: update all dependencies to latest versions

This commit is contained in:
Nick Craig-Wood
2018-01-16 13:20:59 +00:00
parent 8e83fb6fb9
commit 7d3a17725d
4878 changed files with 1974229 additions and 201215 deletions

View File

@@ -62,6 +62,19 @@ func (d *Document) init() error {
// NewDocument unmarshals the bytes into a Document.
// It also validates the document to make sure it is error-free.
func NewDocument(bytes []byte) (*Document, error) {
// The discovery service returns JSON with this format if there's an error, e.g.
// the document isn't found.
var errDoc struct {
Error struct {
Code int
Message string
Status string
}
}
if err := json.Unmarshal(bytes, &errDoc); err == nil && errDoc.Error.Code != 0 {
return nil, fmt.Errorf("bad discovery doc: %+v", errDoc.Error)
}
var doc Document
if err := json.Unmarshal(bytes, &doc); err != nil {
return nil, err

View File

@@ -7,6 +7,7 @@ package disco
import (
"io/ioutil"
"reflect"
"strings"
"testing"
)
@@ -262,3 +263,15 @@ func TestSchemaErrors(t *testing.T) {
}
}
}
func TestErrorDoc(t *testing.T) {
bytes, err := ioutil.ReadFile("testdata/error.json")
if err != nil {
t.Fatal(err)
}
if _, err := NewDocument(bytes); err == nil {
t.Error("got nil, want error")
} else if !strings.Contains(err.Error(), "404") {
t.Errorf("got %v, want 404", err)
}
}

View File

@@ -0,0 +1,7 @@
{
"error": {
"code": 404,
"message": "Discovery document not found for API service: container.googleapis.com format: rest version: v1alpha1",
"status": "NOT_FOUND"
}
}