From 434973c2061b2e384954ce61d43130be6f953a9e Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sun, 12 Feb 2023 20:08:02 +0800 Subject: [PATCH] fix: test failure (#2874) --- core/mapping/unmarshaler.go | 6 ++++-- core/mapping/unmarshaler_test.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/mapping/unmarshaler.go b/core/mapping/unmarshaler.go index b3543d79..c40e34ae 100644 --- a/core/mapping/unmarshaler.go +++ b/core/mapping/unmarshaler.go @@ -853,10 +853,12 @@ func (u *Unmarshaler) unmarshalWithFullName(m valuerWithParent, v any, fullName numFields := baseType.NumField() for i := 0; i < numFields; i++ { - if !baseType.Field(i).IsExported() { + field := baseType.Field(i) + if !field.IsExported() { continue } - if err := u.processField(baseType.Field(i), valElem.Field(i), m, fullName); err != nil { + + if err := u.processField(field, valElem.Field(i), m, fullName); err != nil { return err } } diff --git a/core/mapping/unmarshaler_test.go b/core/mapping/unmarshaler_test.go index 4d9dd98b..b756fba6 100644 --- a/core/mapping/unmarshaler_test.go +++ b/core/mapping/unmarshaler_test.go @@ -793,7 +793,9 @@ func TestUnmarshalStringMapFromNotSettableValue(t *testing.T) { } ast := assert.New(t) - ast.Error(UnmarshalKey(m, &v)) + ast.NoError(UnmarshalKey(m, &v)) + assert.Empty(t, v.sort) + assert.Nil(t, v.psort) } func TestUnmarshalStringMapFromString(t *testing.T) {