-
Notifications
You must be signed in to change notification settings - Fork 1
/
subjectview_test.go
52 lines (38 loc) · 1.2 KB
/
subjectview_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
package store4_test
import (
. "github.com/jimsmart/store4"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
type Tuple struct {
P string
O interface{}
}
func (t Tuple) Predicate() string { return t.P }
func (t Tuple) Object() interface{} { return t.O }
var _ = Describe("SubjectView", func() {
Describe("Creating a single SubjectView from a QuadStore", func() {
Context("with an existing subject and wildcard graph", func() {
store := NewQuadStore([][4]string{
{"s1", "p1", "o1", ""},
{"s1", "p1", "o2", ""},
{"s1", "p2", "o2", ""},
{"s2", "p1", "o1", ""},
{"s1", "p2", "o3", "c4"},
})
view := store.SubjectView("s1", "*")
It("should have size 4", func() {
Expect(view.Size()).To(Equal(uint64(4)))
})
It("should contain the correct predicates", func() {
Expect(view.FindPredicates("*")).To(ConsistOf([]string{"p1", "p2"}))
})
It("should contain the correct object values for predicate p1", func() {
Expect(view.FindObjects("p1")).To(ConsistOf([]string{"o1", "o2"}))
})
It("should contain the correct object values for predicate p2", func() {
Expect(view.FindObjects("p2")).To(ConsistOf([]string{"o2", "o3"}))
})
})
})
})