mirror of
https://github.com/gin-gonic/gin.git
synced 2025-04-06 03:57:46 +08:00
24 lines
452 B
Go
24 lines
452 B
Go
package errorparser
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseBindError(t *testing.T) {
|
|
|
|
_, ok := ParseBindError(fmt.Errorf("not match"))
|
|
assert.False(t, ok)
|
|
|
|
_, ok = ParseBindError(validator.ValidationErrors([]validator.FieldError{}))
|
|
assert.True(t, ok)
|
|
|
|
_, ok = ParseBindError(&json.SyntaxError{})
|
|
assert.True(t, ok)
|
|
|
|
}
|