-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaggs-not-injectable_test.go
More file actions
81 lines (66 loc) · 1.96 KB
/
aggs-not-injectable_test.go
File metadata and controls
81 lines (66 loc) · 1.96 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package aggretastic
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func makeInjection_not(agg, inj Aggregation, x bool, path ...string) {
var injectErr error
if x {
injectErr = agg.InjectX(inj, path...)
} else {
injectErr = agg.Inject(inj, path...)
}
Expect(injectErr).Should(HaveOccurred())
}
func testNotInjection(maxAgg, avgAgg Aggregation, maxAggSource, avgAggSource interface{}, x bool) {
makeInjection_not(maxAgg, avgAgg, x, "any_path")
equal := compareAggregationToSource(maxAgg, maxAggSource)
Expect(equal).To(Equal(true))
maxAggSource, _ = maxAgg.Source()
makeInjection_not(maxAgg, avgAgg, x, "any_path", "other_path")
equal = compareAggregationToSource(maxAgg, maxAggSource)
Expect(equal).To(Equal(true))
}
var _ = Describe("Injectable", func() {
var maxAgg *AvgBucketAggregation
var maxAggSource interface{}
var avgAgg *AvgAggregation
var avgAggSource interface{}
BeforeEach(func() {
maxAgg = NewAvgBucketAggregation()
maxAggSource, _ = maxAgg.Source()
avgAgg = NewAvgAggregation()
avgAggSource, _ = avgAgg.Source()
})
Describe(" Injects", func() {
It(" should not inject aggregations", func() {
testNotInjection(maxAgg, avgAgg, maxAggSource, avgAggSource, false)
})
It(" should not injectX aggregations", func() {
testNotInjection(maxAgg, avgAgg, maxAggSource, avgAggSource, true)
})
})
Describe(" Getters", func() {
It(" should not select aggregations", func() {
sel := maxAgg.Select("any_path")
Expect(sel).To(BeNil())
})
It(" should not pop aggregations", func() {
refSrc, _ := maxAgg.Source()
pop := maxAgg.Pop("any_path")
Expect(pop).To(BeNil())
Expect(maxAgg.Source()).To(Equal(refSrc))
})
})
Describe(" Exports", func() {
It(" should export root", func() {
root := maxAgg.Export()
Expect(root).To(Equal(maxAgg))
})
It(" should export source", func() {
src, err := maxAgg.Source()
Expect(src).NotTo(BeNil())
Expect(err).ShouldNot(HaveOccurred())
})
})
})