支持提取指定的值到一个字段,形成列表

This commit is contained in:
2023-01-02 22:12:48 +08:00
parent 123c22e8b2
commit 3dff92188f
4 changed files with 60 additions and 42 deletions

View File

@ -9,8 +9,9 @@ package filter
import (
"fmt"
"github.com/smartystreets/goconvey/convey"
"testing"
"github.com/smartystreets/goconvey/convey"
)
// TestNewFilter ...
@ -77,3 +78,43 @@ func TestNewFilter(t *testing.T) {
fmt.Println(f.String())
})
}
// TestNewFilterForArrayOne ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 21:43 2023/1/2
func TestNewFilterForArrayOne(t *testing.T) {
var (
err error
)
testData := `[
{
"name":"zhangdeman"
},
{
"name":"zhang"
},
{
"name":"de"
},
{
"name":"man"
}
]`
filterRuleList := []MapRule{
{
SourcePath: "[].name",
MapPath: "user_name.[]",
Required: true,
DataType: "string",
DefaultValue: "",
},
}
f := NewFilter(testData, filterRuleList)
convey.Convey("提取列表字段,构成新的列表", t, func() {
err = f.Deal()
convey.So(err, convey.ShouldEqual, nil)
fmt.Println(f.String())
})
}