-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfrastructures_test.go
65 lines (51 loc) · 1.47 KB
/
infrastructures_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
package deferr_test
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/marconi/deferr"
)
type FakeStoreHandler struct {
deferr.StoreHandler
}
func (fsh *FakeStoreHandler) Size() int {
return len(fsh.Items)
}
func TestStoreHandlerSpec(t *testing.T) {
handler := &FakeStoreHandler{}
Convey("testing store handler", t, func() {
Convey("should be able to push item", func() {
t := &deferr.Todo{Name: "Wash clothes"}
err := handler.Push(t)
So(err, ShouldBeNil)
So(handler.Size(), ShouldEqual, 1)
})
Convey("should be able to query items", func() {
items := handler.Query()
So(items, ShouldNotBeNil)
So(len(items), ShouldEqual, 1)
})
Convey("should be able to defer item", func() {
t := &deferr.Todo{Name: "Sweep the floor"}
handler.Push(t)
So(handler.Size(), ShouldEqual, 2)
items := handler.Query()
So(items[0].(*deferr.Todo).Name, ShouldEqual, "Wash clothes")
So(items[1].(*deferr.Todo).Name, ShouldEqual, "Sweep the floor")
err := handler.Defer()
So(err, ShouldBeNil)
items = handler.Query()
So(items[0].(*deferr.Todo).Name, ShouldEqual, "Sweep the floor")
So(items[1].(*deferr.Todo).Name, ShouldEqual, "Wash clothes")
})
Convey("should be able to pop item", func() {
item, err := handler.Pop()
So(err, ShouldBeNil)
So(item, ShouldNotBeNil)
So(handler.Size(), ShouldEqual, 1)
handler.Pop()
item, err = handler.Pop()
So(err, ShouldNotBeNil)
So(item, ShouldBeNil)
})
})
}