Skip to content

Commit f96cd6c

Browse files
committed
Add more explicit quote test cases
Add two more test cases to explicitly check for quoting with different types.
1 parent 4224e26 commit f96cd6c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

output_json_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,35 @@ var _ = Describe("JSON output", func() {
121121
}`))
122122
})
123123

124+
It("should create compact JSON with correct quotes for different types", func() {
125+
result, err := ToJSONString([]interface{}{
126+
"string",
127+
42.0,
128+
42,
129+
true,
130+
})
131+
132+
Expect(err).To(BeNil())
133+
Expect(result).To(BeEquivalentTo(`["string", 42, 42, true]`))
134+
})
135+
136+
It("should create JSON with correct quotes for different types", func() {
137+
result, err := NewOutputProcessor(true, true, &DefaultColorSchema).ToJSON([]interface{}{
138+
"string",
139+
42.0,
140+
42,
141+
true,
142+
})
143+
144+
Expect(err).To(BeNil())
145+
Expect(result).To(BeEquivalentTo(`[
146+
"string",
147+
42,
148+
42,
149+
true
150+
]`))
151+
})
152+
124153
It("should not create JSON output with unquoted timestamps (https://github.com/gonvenience/neat/issues/69)", func() {
125154
example := func() *yamlv3.Node {
126155
var node yamlv3.Node

0 commit comments

Comments
 (0)