-
Notifications
You must be signed in to change notification settings - Fork 13
/
api_subscribe_test.go
54 lines (49 loc) · 2.11 KB
/
api_subscribe_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
package multichain
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("ApiSubscribes", func() {
DescribeTable("appendInnerParams function derives inner params correctly for",
func(indexTypes []IndexType, retrieveAllOffchain bool, expected []interface{}) {
actual, err := appendInnerParams(indexTypes, retrieveAllOffchain, []interface{}{})
Expect(err).ToNot(HaveOccurred())
Expect(actual).To(Equal(expected))
},
Entry("no index types and retrieveAllOffchain = false",
[]IndexType{}, false,
[]interface{}{}),
Entry("no index types and retrieveAllOffchain = true",
[]IndexType{}, true,
[]interface{}{"retrieve"}),
Entry("one index type and retrieveAllOffchain = false",
[]IndexType{ IndexItems }, false,
[]interface{}{ string(IndexItems) }),
Entry("one index type and retrieveAllOffchain = true",
[]IndexType{ IndexItems }, true,
[]interface{}{ fmt.Sprintf("%s,%s", IndexItems, "retrieve") }),
Entry("some index types and retrieveAllOffchain = false",
[]IndexType{ IndexItems, IndexKeys, IndexKeysLocal }, false,
[]interface{}{ fmt.Sprintf("%s,%s,%s", IndexItems, IndexKeys, IndexKeysLocal) }),
Entry("some index types and retrieveAllOffchain = true",
[]IndexType{ IndexItems, IndexKeys, IndexKeysLocal }, true,
[]interface{}{ fmt.Sprintf("%s,%s,%s,%s", IndexItems, IndexKeys, IndexKeysLocal, "retrieve") }),
Entry("duplicated index types",
[]IndexType{ IndexItems, IndexKeys, IndexKeys }, false,
[]interface{}{ fmt.Sprintf("%s,%s", IndexItems, IndexKeys) }),
)
DescribeTable("appendInnerParams function fails for invalid data due to",
func(indexTypes []IndexType, retrieveAllOffchain bool) {
_, err := appendInnerParams(indexTypes, retrieveAllOffchain, []interface{}{})
Expect(err).To(HaveOccurred())
},
Entry("one IndexItem of multiple invalid",
[]IndexType{ IndexItems, IndexKeys, "not-valid" }, false),
Entry("multiple IndexItems invalid",
[]IndexType{ "not-valid", "not-valid-at-all" }, false),
Entry("one single IndexItem invalid",
[]IndexType{ "not-valid" }, false),
)
})