You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
704 B
Go
40 lines
704 B
Go
3 years ago
|
package dartgen
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
||
|
)
|
||
|
|
||
|
func Test_getPropertyFromMember(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
member spec.Member
|
||
|
want string
|
||
|
}{
|
||
|
{
|
||
|
name: "json tag should be ok",
|
||
|
member: spec.Member{
|
||
|
Tag: "`json:\"foo\"`",
|
||
|
Name: "Foo",
|
||
|
},
|
||
|
want: "foo",
|
||
|
},
|
||
|
{
|
||
|
name: "form tag should be ok",
|
||
|
member: spec.Member{
|
||
|
Tag: "`form:\"bar\"`",
|
||
|
Name: "Bar",
|
||
|
},
|
||
|
want: "bar",
|
||
|
},
|
||
|
}
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
if got := getPropertyFromMember(tt.member); got != tt.want {
|
||
|
t.Errorf("getPropertyFromMember() = %v, want %v", got, tt.want)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|