-
Notifications
You must be signed in to change notification settings - Fork 0
/
container_test.go
51 lines (38 loc) · 921 Bytes
/
container_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
package resozyme
import (
"context"
"testing"
)
func TestResourceContainer(t *testing.T) {
rcont := &ResourceContainer{}
resc := newHelloResource(context.Background())
rcont.Set(resc)
if !rcont.Exists() {
t.Fatal("unexpected existence: want=true, got=false")
}
got := rcont.Get()
if got != resc {
t.Fatalf("unexpected gotten: want=%v, got=%v", resc, got)
}
}
func TestResourceContainer_ByDefault(t *testing.T) {
rcont := &ResourceContainer{}
if rcont.Exists() {
t.Fatal("unexpected existence: want=false, got=true")
}
got := rcont.Get()
if got != nil {
t.Fatalf("unexpected gotten: want=nil, got=%v", got)
}
}
func TestResourceContainer_SetNil(t *testing.T) {
rcont := &ResourceContainer{}
rcont.Set(nil)
if rcont.Exists() {
t.Fatal("unexpected existence: want=false, got=true")
}
got := rcont.Get()
if got != nil {
t.Fatalf("unexpected gotten: want=nil, got=%v", got)
}
}