mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
update vendor/ dir to latest w/o heroku, moby
had to lock a lot of things in place
This commit is contained in:
35
vendor/github.com/gin-gonic/gin/errors_test.go
generated
vendored
35
vendor/github.com/gin-gonic/gin/errors_test.go
generated
vendored
@@ -5,10 +5,10 @@
|
||||
package gin
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin/json"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestError(t *testing.T) {
|
||||
})
|
||||
|
||||
jsonBytes, _ := json.Marshal(err)
|
||||
assert.Equal(t, string(jsonBytes), "{\"error\":\"test error\",\"meta\":\"some data\"}")
|
||||
assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
|
||||
|
||||
err.SetMeta(H{
|
||||
"status": "200",
|
||||
@@ -54,6 +54,13 @@ func TestError(t *testing.T) {
|
||||
"status": "200",
|
||||
"data": "some data",
|
||||
})
|
||||
|
||||
type customError struct {
|
||||
status string
|
||||
data string
|
||||
}
|
||||
err.SetMeta(customError{status: "200", data: "other data"})
|
||||
assert.Equal(t, customError{status: "200", data: "other data"}, err.JSON())
|
||||
}
|
||||
|
||||
func TestErrorSlice(t *testing.T) {
|
||||
@@ -64,33 +71,33 @@ func TestErrorSlice(t *testing.T) {
|
||||
}
|
||||
|
||||
assert.Equal(t, errs, errs.ByType(ErrorTypeAny))
|
||||
assert.Equal(t, errs.Last().Error(), "third")
|
||||
assert.Equal(t, errs.Errors(), []string{"first", "second", "third"})
|
||||
assert.Equal(t, errs.ByType(ErrorTypePublic).Errors(), []string{"third"})
|
||||
assert.Equal(t, errs.ByType(ErrorTypePrivate).Errors(), []string{"first", "second"})
|
||||
assert.Equal(t, errs.ByType(ErrorTypePublic|ErrorTypePrivate).Errors(), []string{"first", "second", "third"})
|
||||
assert.Equal(t, "third", errs.Last().Error())
|
||||
assert.Equal(t, []string{"first", "second", "third"}, errs.Errors())
|
||||
assert.Equal(t, []string{"third"}, errs.ByType(ErrorTypePublic).Errors())
|
||||
assert.Equal(t, []string{"first", "second"}, errs.ByType(ErrorTypePrivate).Errors())
|
||||
assert.Equal(t, []string{"first", "second", "third"}, errs.ByType(ErrorTypePublic|ErrorTypePrivate).Errors())
|
||||
assert.Empty(t, errs.ByType(ErrorTypeBind))
|
||||
assert.Empty(t, errs.ByType(ErrorTypeBind).String())
|
||||
|
||||
assert.Equal(t, errs.String(), `Error #01: first
|
||||
assert.Equal(t, `Error #01: first
|
||||
Error #02: second
|
||||
Meta: some data
|
||||
Error #03: third
|
||||
Meta: map[status:400]
|
||||
`)
|
||||
assert.Equal(t, errs.JSON(), []interface{}{
|
||||
`, errs.String())
|
||||
assert.Equal(t, []interface{}{
|
||||
H{"error": "first"},
|
||||
H{"error": "second", "meta": "some data"},
|
||||
H{"error": "third", "status": "400"},
|
||||
})
|
||||
}, errs.JSON())
|
||||
jsonBytes, _ := json.Marshal(errs)
|
||||
assert.Equal(t, string(jsonBytes), "[{\"error\":\"first\"},{\"error\":\"second\",\"meta\":\"some data\"},{\"error\":\"third\",\"status\":\"400\"}]")
|
||||
assert.Equal(t, "[{\"error\":\"first\"},{\"error\":\"second\",\"meta\":\"some data\"},{\"error\":\"third\",\"status\":\"400\"}]", string(jsonBytes))
|
||||
errs = errorMsgs{
|
||||
{Err: errors.New("first"), Type: ErrorTypePrivate},
|
||||
}
|
||||
assert.Equal(t, errs.JSON(), H{"error": "first"})
|
||||
assert.Equal(t, H{"error": "first"}, errs.JSON())
|
||||
jsonBytes, _ = json.Marshal(errs)
|
||||
assert.Equal(t, string(jsonBytes), "{\"error\":\"first\"}")
|
||||
assert.Equal(t, "{\"error\":\"first\"}", string(jsonBytes))
|
||||
|
||||
errs = errorMsgs{}
|
||||
assert.Nil(t, errs.Last())
|
||||
|
||||
Reference in New Issue
Block a user