Round 2
Make Errors a []Error Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
parent
f565d6abb7
commit
00b1e8fca0
13 changed files with 98 additions and 116 deletions
|
@ -86,15 +86,12 @@ func TestUploadReadFrom(t *testing.T) {
|
|||
Response: testutil.Response{
|
||||
StatusCode: http.StatusBadRequest,
|
||||
Body: []byte(`
|
||||
{
|
||||
"errors": [
|
||||
[
|
||||
{
|
||||
"code": "BLOB_UPLOAD_INVALID",
|
||||
"message": "invalid upload identifier",
|
||||
"detail": "more detail"
|
||||
}
|
||||
]
|
||||
}`),
|
||||
] `),
|
||||
},
|
||||
},
|
||||
// Test 400 invalid json
|
||||
|
@ -162,17 +159,17 @@ func TestUploadReadFrom(t *testing.T) {
|
|||
if err == nil {
|
||||
t.Fatalf("Expected error when not found")
|
||||
}
|
||||
if uploadErr, ok := err.(*errcode.Errors); !ok {
|
||||
if uploadErr, ok := err.(errcode.Errors); !ok {
|
||||
t.Fatalf("Wrong error type %T: %s", err, err)
|
||||
} else if len(uploadErr.Errors) != 1 {
|
||||
t.Fatalf("Unexpected number of errors: %d, expected 1", len(uploadErr.Errors))
|
||||
} else if len(uploadErr) != 1 {
|
||||
t.Fatalf("Unexpected number of errors: %d, expected 1", len(uploadErr))
|
||||
} else {
|
||||
v2Err := uploadErr.Errors[0]
|
||||
v2Err := uploadErr[0]
|
||||
if v2Err.Code != v2.ErrorCodeBlobUploadInvalid {
|
||||
t.Fatalf("Unexpected error code: %s, expected %d", v2Err.Code.String(), v2.ErrorCodeBlobUploadInvalid)
|
||||
}
|
||||
if expected := "invalid upload identifier"; v2Err.Message != expected {
|
||||
t.Fatalf("Unexpected error message: %s, expected %s", v2Err.Message, expected)
|
||||
if expected := "blob upload invalid"; v2Err.Message() != expected {
|
||||
t.Fatalf("Unexpected error message: %s, expected %s", v2Err.Message(), expected)
|
||||
}
|
||||
if expected := "more detail"; v2Err.Detail.(string) != expected {
|
||||
t.Fatalf("Unexpected error message: %s, expected %s", v2Err.Detail.(string), expected)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue