-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtag_test.go
60 lines (56 loc) · 927 Bytes
/
tag_test.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
package rejson
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseTag(t *testing.T) {
tests := []struct {
name string
args string
want tag
}{
{
name: "ignore",
args: "-",
want: tag{
Type: tagTypeIgnore,
Value: "",
},
}, {
name: "empty",
args: "",
want: tag{
Type: tagTypeEmpty,
Value: "",
},
}, {
name: "path",
args: "first_name",
want: tag{
Type: tagTypePath,
Value: "first_name",
},
}, {
name: "func",
args: "func:FormatTime",
want: tag{
Type: tagTypeFunc,
Value: "FormatTime",
},
}, {
name: "complex",
args: "xxx.@comp",
want: tag{
Type: tagTypePath,
Value: "xxx.@comp",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := parseTag(tt.args)
assert.Equal(t, tt.want.Type, got.Type)
assert.Equal(t, tt.want.Value, got.Value)
})
}
}