chore: add more tests (#4949)

This commit is contained in:
Kevin Wan
2025-06-13 22:10:08 +08:00
committed by GitHub
parent 4cacc4d9d3
commit 0ba86b1849
3 changed files with 30 additions and 6 deletions

View File

@@ -13,7 +13,6 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/jsonx"
"github.com/zeromicro/go-zero/core/stringx"
)
@@ -215,7 +214,7 @@ func TestUnmarshalDurationUnexpectedError(t *testing.T) {
var in inner
err = UnmarshalKey(m, &in)
assert.Error(t, err)
assert.Contains(t, err.Error(), "unexpected type")
assert.Contains(t, err.Error(), "expect string")
}
func TestUnmarshalDurationDefault(t *testing.T) {
@@ -6010,6 +6009,16 @@ func TestUnmarshal_Unmarshaler(t *testing.T) {
}, &v))
assert.Nil(t, v.Foo)
})
t.Run("json.Number", func(t *testing.T) {
v := struct {
Foo *mockUnmarshaler `json:"name"`
}{}
m := map[string]any{
"name": json.Number("123"),
}
assert.Error(t, UnmarshalJsonMap(m, &v))
})
}
func TestParseJsonStringValue(t *testing.T) {