chore: optimize yaml unmarshaler (#1513)

This commit is contained in:
chenquan
2022-02-09 02:57:00 -06:00
committed by GitHub
parent 9c2c90e533
commit 05cc62f5ff
2 changed files with 17 additions and 9 deletions

View File

@@ -926,14 +926,18 @@ func TestUnmarshalYamlBytesError(t *testing.T) {
}
func TestUnmarshalYamlReaderError(t *testing.T) {
payload := `abcd: cdef`
reader := strings.NewReader(payload)
var v struct {
Any string
}
reader := strings.NewReader(`abcd: cdef`)
err := UnmarshalYamlReader(reader, &v)
assert.NotNil(t, err)
reader = strings.NewReader("chenquan")
err = UnmarshalYamlReader(reader, &v)
assert.ErrorIs(t, err, ErrUnsupportedType)
}
func TestUnmarshalYamlBadReader(t *testing.T) {
@@ -1011,6 +1015,6 @@ func TestUnmarshalYamlMapRune(t *testing.T) {
type badReader struct{}
func (b *badReader) Read(p []byte) (n int, err error) {
func (b *badReader) Read(_ []byte) (n int, err error) {
return 0, io.ErrLimitReached
}