-
Notifications
You must be signed in to change notification settings - Fork 27
/
di_test.go
68 lines (62 loc) · 1.21 KB
/
di_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
package baa
import (
. "github.com/smartystreets/goconvey/convey"
"log"
"os"
"testing"
)
func TestDISetLogger1(t *testing.T) {
Convey("register error logger", t, func() {
defer func() {
e := recover()
So(e, ShouldNotBeNil)
}()
b := New()
b.SetDI("logger", nil)
})
}
func TestDISetLogger2(t *testing.T) {
Convey("register correct logger", t, func() {
defer func() {
e := recover()
So(e, ShouldBeNil)
}()
b := New()
b.SetDI("logger", log.New(os.Stderr, "BaaTest ", log.LstdFlags))
})
}
func TestDISetRender1(t *testing.T) {
Convey("register error render", t, func() {
defer func() {
e := recover()
So(e, ShouldNotBeNil)
}()
b := New()
b.SetDI("render", nil)
})
}
func TestDISetRender2(t *testing.T) {
Convey("register correct render", t, func() {
defer func() {
e := recover()
So(e, ShouldBeNil)
}()
b := New()
b.SetDI("render", newRender())
})
}
func TestDISet1(t *testing.T) {
Convey("register di", t, func() {
b.SetDI("test", "hiDI")
})
}
func TestDIGet1(t *testing.T) {
Convey("get registerd di", t, func() {
var v interface{}
v = b.GetDI("")
So(v, ShouldBeNil)
v = b.GetDI("test")
So(v, ShouldNotBeNil)
So(v.(string), ShouldEqual, "hiDI")
})
}