fix: unmarshal from number to string with incorrect error message (#3625)

This commit is contained in:
Kevin Wan
2023-10-15 10:06:00 +08:00
committed by GitHub
parent b731aa38af
commit 4f22034342
3 changed files with 15 additions and 5 deletions

View File

@@ -1011,6 +1011,15 @@ func TestUnmarshalYamlMapRune(t *testing.T) {
assert.Equal(t, rune(3), v.Machine["node3"])
}
func TestUnmarshalYamlStringOfInt(t *testing.T) {
text := `password: 123456`
var v struct {
Password string `json:"password"`
}
reader := strings.NewReader(text)
assert.Error(t, UnmarshalYamlReader(reader, &v))
}
func TestUnmarshalYamlBadInput(t *testing.T) {
var v struct {
Any string