-
Notifications
You must be signed in to change notification settings - Fork 40
/
utils_test.go
45 lines (34 loc) · 1 KB
/
utils_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
package bongo
import (
"reflect"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestLowerInitial(t *testing.T) {
Convey("LowerInitial", t, func() {
Convey("ValidateRequired()", func() {
So(lowerInitial("foo"), ShouldEqual, "foo")
So(lowerInitial("Foo"), ShouldEqual, "foo")
So(lowerInitial("Abba"), ShouldEqual, "abba")
So(lowerInitial("ABBA"), ShouldEqual, "aBBA")
So(lowerInitial(""), ShouldEqual, "")
})
})
}
func TestBsonName(t *testing.T) {
Convey("GetBsonName", t, func() {
type Model struct {
Property string `bson:"property" json:"property"`
Property2 string `json:"property3"`
}
Convey("GetBsonName(Model)", func() {
obj := Model{}
val := reflect.Indirect(reflect.ValueOf(obj))
field, _ := val.Type().FieldByName("Property")
So(GetBsonName(field), ShouldEqual, "property")
val2 := reflect.Indirect(reflect.ValueOf(obj))
field2, _ := val2.Type().FieldByName("Property2")
So(GetBsonName(field2), ShouldEqual, "property2")
})
})
}