-
Notifications
You must be signed in to change notification settings - Fork 14
/
yaml_compat_test.go
45 lines (35 loc) · 953 Bytes
/
yaml_compat_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
package patch_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gopkg.in/yaml.v2"
. "github.com/cppforlife/go-patch/patch"
)
var _ = Describe("YAML compatibility", func() {
Describe("empty string", func() {
It("[workaround] works deserializing empty strings", func() {
str := `
- type: replace
path: /instance_groups/name=cloud_controller/instances
value: !!str ""
`
var opDefs []OpDefinition
err := yaml.Unmarshal([]byte(str), &opDefs)
Expect(err).ToNot(HaveOccurred())
val := opDefs[0].Value
Expect((*val).(string)).To(Equal(""))
})
It("[fixed] does not work deserializing empty strings", func() {
str := `
- type: replace
path: /instance_groups/name=cloud_controller/instances
value: ""
`
var opDefs []OpDefinition
err := yaml.Unmarshal([]byte(str), &opDefs)
Expect(err).ToNot(HaveOccurred())
val := opDefs[0].Value
Expect((*val).(string)).To(Equal(""))
})
})
})