mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +08:00
Disable test when using sonic
This commit is contained in:
parent
666545f787
commit
c0db11b473
@ -771,7 +771,7 @@ func (c *Context) BindUri(obj any) error {
|
||||
func (c *Context) MustBindWith(obj any, b binding.Binding) error {
|
||||
err := c.ShouldBindWith(obj, b)
|
||||
if err != nil {
|
||||
maxBytesErr := &http.MaxBytesError{}
|
||||
var maxBytesErr *http.MaxBytesError
|
||||
switch {
|
||||
case errors.As(err, &maxBytesErr):
|
||||
c.AbortWithError(http.StatusRequestEntityTooLarge, err).SetType(ErrorTypeBind) //nolint: errcheck
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
|
||||
"github.com/gin-contrib/sse"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/gin-gonic/gin/internal/json"
|
||||
testdata "github.com/gin-gonic/gin/testdata/protoexample"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -1849,6 +1850,12 @@ func TestContextContentType(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestContextBindRequestTooLarge(t *testing.T) {
|
||||
// Disabling this test when using sonic as JSON encoder because it doesn't cascade the error correctly
|
||||
if json.IsSonic {
|
||||
t.Skip()
|
||||
return
|
||||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
c, _ := CreateTestContext(w)
|
||||
|
||||
|
@ -20,3 +20,6 @@ var (
|
||||
// NewEncoder is exported by gin/json package.
|
||||
NewEncoder = json.NewEncoder
|
||||
)
|
||||
|
||||
// IsSonic indicates whether the sonic library is being used for JSON encoding.
|
||||
const IsSonic = false
|
||||
|
@ -21,3 +21,6 @@ var (
|
||||
// NewEncoder is exported by gin/json package.
|
||||
NewEncoder = json.NewEncoder
|
||||
)
|
||||
|
||||
// IsSonic indicates whether the sonic library is being used for JSON encoding.
|
||||
const IsSonic = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user