mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-04 22:23:21 -04:00
add reflect_test
This commit is contained in:
53
accounts/pkg/indexer/reflect_test.go
Normal file
53
accounts/pkg/indexer/reflect_test.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package indexer
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_getTypeFQN(t *testing.T) {
|
||||
type someT struct{}
|
||||
|
||||
type args struct {
|
||||
t interface{}
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{name: "ByValue", args: args{&someT{}}, want: "github.com.owncloud.ocis.accounts.pkg.indexer.someT"},
|
||||
{name: "ByRef", args: args{someT{}}, want: "github.com.owncloud.ocis.accounts.pkg.indexer.someT"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := getTypeFQN(tt.args.t); got != tt.want {
|
||||
t.Errorf("getTypeFQN() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_valueOf(t *testing.T) {
|
||||
type someT struct {
|
||||
val string
|
||||
}
|
||||
type args struct {
|
||||
v interface{}
|
||||
field string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{name: "ByValue", args: args{v: someT{val: "hello"}, field: "val"}, want: "hello"},
|
||||
{name: "ByRef", args: args{v: &someT{val: "hello"}, field: "val"}, want: "hello"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := valueOf(tt.args.v, tt.args.field); got != tt.want {
|
||||
t.Errorf("valueOf() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user