-
Notifications
You must be signed in to change notification settings - Fork 4
/
paths_test.go
85 lines (69 loc) · 1.7 KB
/
paths_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
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
82
83
84
85
package goml_test
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/JulzDiverse/goml"
)
var _ = XDescribe("Paths", func() {
Context("When retrieving paths of a yaml file", func() {
var (
yaml string
err error
)
//JustBeforeEach(func() {
//sl, _ := GetPaths([]byte(yaml))
//paths = sl
//sl = []string{}
//fmt.Println("PATHS for test", test, paths)
//})
//AfterEach(func() {
//paths = nil
//})
Context("For a simple map", func() {
BeforeEach(func() {
yaml = `---
map:
name: julz`
})
It("should not fail", func() {
Expect(err).ToNot(HaveOccurred())
})
It("should return the paths", func() {
paths, err := GetPaths([]byte(yaml))
Expect(err).ToNot(HaveOccurred())
Expect(paths[0]).To(Equal("map.name"))
})
It("should be a valid goml path", func() {
paths, err := GetPaths([]byte(yaml))
Expect(err).ToNot(HaveOccurred())
result, err := GetInMemory([]byte(yaml), paths[0])
Expect(err).ToNot(HaveOccurred())
Expect(result).To(Equal("julz"))
})
})
Context("For a simple array", func() {
BeforeEach(func() {
yaml = `---
array:
- julz`
})
It("should not fail", func() {
Expect(err).ToNot(HaveOccurred())
})
It("should return the path", func() {
paths, err := GetPaths([]byte(yaml))
Expect(err).ToNot(HaveOccurred())
fmt.Println("PATHS", paths)
Expect(paths[0]).To(Equal("array.0"))
})
It("should be a valid goml path", func() {
paths, err := GetPaths([]byte(yaml))
Expect(err).ToNot(HaveOccurred())
result, err := GetInMemory([]byte(yaml), paths[0])
Expect(err).ToNot(HaveOccurred())
Expect(result).To(Equal("julz"))
})
})
})
})