-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig_test.go
91 lines (73 loc) · 2.12 KB
/
config_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package autumn
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestNewConfig(t *testing.T) {
Convey("Constructs a new default config object", t, func() {
c := NewConfig()
So(c.tagName, ShouldEqual, "autumn")
So(c.leafNameMethod, ShouldEqual, "GetLeafName")
So(c.postConstructMethod, ShouldEqual, "PostConstruct")
So(c.preDestroyMethod, ShouldEqual, "PreDestroy")
})
}
func TestTagName(t *testing.T) {
Convey("Sets the tag name", t, func() {
c := NewConfig().TagName("test")
So(c.tagName, ShouldEqual, "test")
Convey("Panics if the supplied tag name is empty", func() {
So(func() {
NewConfig().TagName("")
}, ShouldPanic)
})
})
}
func TestLeafNameMethod(t *testing.T) {
Convey("Sets the leaf name method", t, func() {
c := NewConfig().LeafNameMethod("Test")
So(c.leafNameMethod, ShouldEqual, "Test")
Convey("Panics if the supplied method name is empty", func() {
So(func() {
NewConfig().LeafNameMethod("")
}, ShouldPanic)
})
Convey("Panics if the supplied method name isn't public", func() {
So(func() {
NewConfig().LeafNameMethod("getLeafName")
}, ShouldPanic)
})
})
}
func TestPostConstructMethod(t *testing.T) {
Convey("Sets the post construct method", t, func() {
c := NewConfig().PostConstructMethod("Test")
So(c.postConstructMethod, ShouldEqual, "Test")
Convey("Panics if the supplied method name is empty", func() {
So(func() {
NewConfig().PostConstructMethod("")
}, ShouldPanic)
})
Convey("Panics if the supplied method name isn't public", func() {
So(func() {
NewConfig().PostConstructMethod("postConstruct")
}, ShouldPanic)
})
})
}
func TestPreDestroyMethod(t *testing.T) {
Convey("Sets the pre destroy method", t, func() {
c := NewConfig().PreDestroyMethod("Test")
So(c.preDestroyMethod, ShouldEqual, "Test")
Convey("Panics if the supplied method name is empty", func() {
So(func() {
NewConfig().PreDestroyMethod("")
}, ShouldPanic)
})
Convey("Panics if the supplied method name isn't public", func() {
So(func() {
NewConfig().PreDestroyMethod("postConstruct")
}, ShouldPanic)
})
})
}