-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci_map_test.go
54 lines (51 loc) · 1.1 KB
/
ci_map_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 alligotor
import (
"encoding/json"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("ciMap", func() {
var (
ciMap *ciMap
jsonBytes = []byte(`{
"test": {
"innertest": "arrrr",
"innertest2": "pirate"
},
"test2": "idk"
}`)
)
BeforeEach(func() {
ciMap = newCiMap()
Expect(json.Unmarshal(jsonBytes, ciMap)).To(Succeed())
})
Describe("Get", func() {
Context("nested", func() {
It("works", func() {
val, ok := ciMap.Get([]string{"test"}, "innertest")
Expect(ok).To(BeTrue())
Expect(val).To(Equal("arrrr"))
})
})
Context("case insensitive", func() {
It("works", func() {
val, ok := ciMap.Get([]string{"test"}, "INNERTEST2")
Expect(ok).To(BeTrue())
Expect(val).To(Equal("pirate"))
})
})
Context("in root", func() {
It("works", func() {
val, ok := ciMap.Get(nil, "TEST2")
Expect(ok).To(BeTrue())
Expect(val).To(Equal("idk"))
})
})
Context("key does not exist", func() {
It("should return ok=false", func() {
_, ok := ciMap.Get(nil, "not-existing")
Expect(ok).To(BeFalse())
})
})
})
})