-
-
Notifications
You must be signed in to change notification settings - Fork 79
/
service_eager_test.go
45 lines (33 loc) · 936 Bytes
/
service_eager_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 do
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestServiceEagerName(t *testing.T) {
is := assert.New(t)
type test struct {
foobar string
}
_test := test{foobar: "foobar"}
service1 := newServiceEager("foobar", 42)
is.Equal("foobar", service1.getName())
service2 := newServiceEager("foobar", _test)
is.Equal("foobar", service2.getName())
}
func TestServiceEagerInstance(t *testing.T) {
is := assert.New(t)
type test struct {
foobar string
}
_test := test{foobar: "foobar"}
service1 := newServiceEager("foobar", _test)
is.Equal(&ServiceEager[test]{name: "foobar", instance: _test}, service1)
instance1, err1 := service1.getInstance(nil)
is.Nil(err1)
is.Equal(_test, instance1)
service2 := newServiceEager("foobar", 42)
is.Equal(&ServiceEager[int]{name: "foobar", instance: 42}, service2)
instance2, err2 := service2.getInstance(nil)
is.Nil(err2)
is.Equal(42, instance2)
}