mirror of https://github.com/gin-gonic/gin.git
update assert param(expect, actual) position (#1421)
- update assert param(expect, actual) position
This commit is contained in:
parent
1c4cbfae59
commit
d17a12591f
|
@ -19,17 +19,17 @@ func TestError(t *testing.T) {
|
||||||
Type: ErrorTypePrivate,
|
Type: ErrorTypePrivate,
|
||||||
}
|
}
|
||||||
assert.Equal(t, err.Error(), baseError.Error())
|
assert.Equal(t, err.Error(), baseError.Error())
|
||||||
assert.Equal(t, err.JSON(), H{"error": baseError.Error()})
|
assert.Equal(t, H{"error": baseError.Error()}, err.JSON())
|
||||||
|
|
||||||
assert.Equal(t, err.SetType(ErrorTypePublic), err)
|
assert.Equal(t, err.SetType(ErrorTypePublic), err)
|
||||||
assert.Equal(t, err.Type, ErrorTypePublic)
|
assert.Equal(t, ErrorTypePublic, err.Type)
|
||||||
|
|
||||||
assert.Equal(t, err.SetMeta("some data"), err)
|
assert.Equal(t, err.SetMeta("some data"), err)
|
||||||
assert.Equal(t, err.Meta, "some data")
|
assert.Equal(t, "some data", err.Meta)
|
||||||
assert.Equal(t, err.JSON(), H{
|
assert.Equal(t, H{
|
||||||
"error": baseError.Error(),
|
"error": baseError.Error(),
|
||||||
"meta": "some data",
|
"meta": "some data",
|
||||||
})
|
}, err.JSON())
|
||||||
|
|
||||||
jsonBytes, _ := json.Marshal(err)
|
jsonBytes, _ := json.Marshal(err)
|
||||||
assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
|
assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
|
||||||
|
@ -38,22 +38,22 @@ func TestError(t *testing.T) {
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
})
|
||||||
assert.Equal(t, err.JSON(), H{
|
assert.Equal(t, H{
|
||||||
"error": baseError.Error(),
|
"error": baseError.Error(),
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
}, err.JSON())
|
||||||
|
|
||||||
err.SetMeta(H{
|
err.SetMeta(H{
|
||||||
"error": "custom error",
|
"error": "custom error",
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
})
|
||||||
assert.Equal(t, err.JSON(), H{
|
assert.Equal(t, H{
|
||||||
"error": "custom error",
|
"error": "custom error",
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
}, err.JSON())
|
||||||
|
|
||||||
type customError struct {
|
type customError struct {
|
||||||
status string
|
status string
|
||||||
|
|
|
@ -51,7 +51,7 @@ func TestResponseWriterWriteHeader(t *testing.T) {
|
||||||
w.WriteHeader(300)
|
w.WriteHeader(300)
|
||||||
assert.False(t, w.Written())
|
assert.False(t, w.Written())
|
||||||
assert.Equal(t, 300, w.Status())
|
assert.Equal(t, 300, w.Status())
|
||||||
assert.NotEqual(t, testWritter.Code, 300)
|
assert.NotEqual(t, 300, testWritter.Code)
|
||||||
|
|
||||||
w.WriteHeader(-1)
|
w.WriteHeader(-1)
|
||||||
assert.Equal(t, 300, w.Status())
|
assert.Equal(t, 300, w.Status())
|
||||||
|
|
Loading…
Reference in New Issue