fix endless recursion in wmo reflection
This commit is contained in:
@@ -113,19 +113,25 @@ func TestReflectionGetTokenValueAsMongoType(t *testing.T) {
|
||||
|
||||
type IDType string
|
||||
|
||||
type RecurseiveType struct {
|
||||
Other int `bson:"other"`
|
||||
Inner *RecurseiveType `bson:"inner"`
|
||||
}
|
||||
|
||||
type TestData struct {
|
||||
ID IDType `bson:"_id"`
|
||||
CDate time.Time `bson:"cdate"`
|
||||
Sub struct {
|
||||
A string `bson:"a"`
|
||||
} `bson:"sub"`
|
||||
SubPtr struct {
|
||||
SubPtr *struct {
|
||||
A string `bson:"a"`
|
||||
} `bson:"subPtr"`
|
||||
Str string `bson:"str"`
|
||||
Ptr *int `bson:"ptr"`
|
||||
Num int `bson:"num"`
|
||||
MDate rfctime.RFC3339NanoTime `bson:"mdate"`
|
||||
Rec RecurseiveType `bson:"rec"`
|
||||
}
|
||||
|
||||
coll := W[TestData](&mongo.Collection{})
|
||||
@@ -149,6 +155,7 @@ func TestReflectionGetTokenValueAsMongoType(t *testing.T) {
|
||||
tst.AssertEqual(t, gtvasmt("hello", "str").(string), "hello")
|
||||
tst.AssertEqual(t, gtvasmt("hello", "sub.a").(string), "hello")
|
||||
tst.AssertEqual(t, gtvasmt("hello", "subPtr.a").(string), "hello")
|
||||
tst.AssertEqual(t, gtvasmt("4", "rec.other").(int), 4)
|
||||
tst.AssertEqual(t, gtvasmt("4", "num").(int), 4)
|
||||
tst.AssertEqual(t, gtvasmt("asdf", "_id").(IDType), "asdf")
|
||||
tst.AssertEqual(t, gtvasmt("", "ptr").(*int), nil)
|
||||
|
Reference in New Issue
Block a user