248 lines
5.0 KiB
Go
248 lines
5.0 KiB
Go
package annotation
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func Test_newRegistry(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
want Regist
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := newRegistry(); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("newRegistry() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRegister(t *testing.T) {
|
|
type args struct {
|
|
t reflect.Type
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
Register(tt.args.t)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRegistry_Register(t *testing.T) {
|
|
type fields struct {
|
|
definitions map[string]*Definition
|
|
}
|
|
type args struct {
|
|
t reflect.Type
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &Registry{
|
|
definitions: tt.fields.definitions,
|
|
}
|
|
r.Register(tt.args.t)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestParse(t *testing.T) {
|
|
type args struct {
|
|
tag reflect.StructTag
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want map[reflect.Type]Annotation
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := Parse(tt.args.tag)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Parse() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("Parse() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRegistry_Parse(t *testing.T) {
|
|
type fields struct {
|
|
definitions map[string]*Definition
|
|
}
|
|
type args struct {
|
|
tag reflect.StructTag
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want map[reflect.Type]Annotation
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &Registry{
|
|
definitions: tt.fields.definitions,
|
|
}
|
|
got, err := r.Parse(tt.args.tag)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Registry.Parse() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("Registry.Parse() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRegistry_getTypeAnnotationField(t *testing.T) {
|
|
type fields struct {
|
|
definitions map[string]*Definition
|
|
}
|
|
type args struct {
|
|
t reflect.Type
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want *reflect.StructField
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &Registry{
|
|
definitions: tt.fields.definitions,
|
|
}
|
|
if got := r.getTypeAnnotationField(tt.args.t); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("Registry.getTypeAnnotationField() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRegistry_parseAnnotationMeta(t *testing.T) {
|
|
type fields struct {
|
|
definitions map[string]*Definition
|
|
}
|
|
type args struct {
|
|
tag reflect.StructTag
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want string
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &Registry{
|
|
definitions: tt.fields.definitions,
|
|
}
|
|
if got := r.parseAnnotationMeta(tt.args.tag); got != tt.want {
|
|
t.Errorf("Registry.parseAnnotationMeta() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRegistry_splitAnnotation(t *testing.T) {
|
|
type fields struct {
|
|
definitions map[string]*Definition
|
|
}
|
|
type args struct {
|
|
s string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want map[string]string
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &Registry{
|
|
definitions: tt.fields.definitions,
|
|
}
|
|
got, err := r.splitAnnotation(tt.args.s)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Registry.splitAnnotation() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("Registry.splitAnnotation() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRegistry_buildAnnotation(t *testing.T) {
|
|
type fields struct {
|
|
definitions map[string]*Definition
|
|
}
|
|
type args struct {
|
|
name string
|
|
attributes string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want reflect.Type
|
|
want1 Annotation
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
r := &Registry{
|
|
definitions: tt.fields.definitions,
|
|
}
|
|
got, got1, err := r.buildAnnotation(tt.args.name, tt.args.attributes)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Registry.buildAnnotation() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("Registry.buildAnnotation() got = %v, want %v", got, tt.want)
|
|
}
|
|
if !reflect.DeepEqual(got1, tt.want1) {
|
|
t.Errorf("Registry.buildAnnotation() got1 = %v, want %v", got1, tt.want1)
|
|
}
|
|
})
|
|
}
|
|
}
|