mirror of
https://github.com/gin-gonic/gin.git
synced 2025-08-24 07:55:38 +08:00
fix json sort the map keys
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@ -8,7 +8,6 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
json "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -32,7 +31,7 @@ func TestError(t *testing.T) {
|
||||
})
|
||||
|
||||
jsonBytes, _ := json.Marshal(err)
|
||||
assert.Equal(t, "{\"meta\":\"some data\",\"error\":\"test error\"}", string(jsonBytes))
|
||||
assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
|
||||
|
||||
err.SetMeta(H{
|
||||
"status": "200",
|
||||
@ -91,7 +90,7 @@ Error #03: third
|
||||
H{"error": "third", "status": "400"},
|
||||
})
|
||||
jsonBytes, _ := json.Marshal(errs)
|
||||
assert.Equal(t, "[{\"error\":\"first\"},{\"meta\":\"some data\",\"error\":\"second\"},{\"status\":\"400\",\"error\":\"third\"}]", string(jsonBytes))
|
||||
assert.Equal(t, "[{\"error\":\"first\"},{\"error\":\"second\",\"meta\":\"some data\"},{\"error\":\"third\",\"status\":\"400\"}]", string(jsonBytes))
|
||||
errs = errorMsgs{
|
||||
{Err: errors.New("first"), Type: ErrorTypePrivate},
|
||||
}
|
||||
|
Reference in New Issue
Block a user