-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcollection_test.go
56 lines (46 loc) · 981 Bytes
/
collection_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
package y
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Collection", func() {
type something struct {
ID int64 `y:"id,pk"`
}
Context("when one item added", func() {
var (
ptr *something
c *Collection
)
BeforeEach(func() {
ptr = &something{ID: 1}
c = New(ptr).Collection()
})
It("should be non-empty", func() {
Expect(c.Empty()).To(BeFalse())
})
It("should be contain the first item", func() {
Expect(c.First()).To(Equal(ptr))
})
})
Context("when two items added", func() {
var (
ptrs []*something
c *Collection
)
BeforeEach(func() {
ptrs = make([]*something, 2)
for i, id := range []int64{1, 2} {
ptr := &something{ID: id}
ptrs[i] = ptr
}
c = New(ptrs).Collection()
})
It("should contain two items", func() {
Expect(c.Size()).To(Equal(2))
})
It("should list correct sequence of items", func() {
Expect(c.List()).To(Equal(ptrs))
})
})
})