removefieldfilter_test.go
841 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package filter
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRemoveFieldFilter(t *testing.T) {
tests := []struct {
name string
input map[string]interface{}
fields []string
expect map[string]interface{}
}{
{
name: "remove field",
input: map[string]interface{}{
"a": "aa",
"b": `{"c":"cc"}`,
},
fields: []string{"b"},
expect: map[string]interface{}{
"a": "aa",
},
},
{
name: "remove field",
input: map[string]interface{}{
"a": "aa",
"b": `{"c":"cc"}`,
},
fields: []string{"c"},
expect: map[string]interface{}{
"a": "aa",
"b": `{"c":"cc"}`,
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual := RemoveFieldFilter(test.fields)(test.input)
assert.EqualValues(t, test.expect, actual)
})
}
}