mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
add tests for root node unwrap bug in previous versions (#1837)
This commit is contained in:
parent
c8f4ba7f45
commit
a60d27975a
@ -72,6 +72,15 @@ EOL
|
|||||||
assertEquals "\"cat\"" "$X"
|
assertEquals "\"cat\"" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testOutputYamlRawOnRoot() {
|
||||||
|
cat >test.yml <<EOL
|
||||||
|
'a'
|
||||||
|
EOL
|
||||||
|
|
||||||
|
X=$(./yq e -r '.' test.yml)
|
||||||
|
assertEquals "a" "$X"
|
||||||
|
}
|
||||||
|
|
||||||
testOutputJsonRaw() {
|
testOutputJsonRaw() {
|
||||||
cat >test.yml <<EOL
|
cat >test.yml <<EOL
|
||||||
a: cat
|
a: cat
|
||||||
|
@ -390,3 +390,23 @@ func TestPrinterNulSeparatorWithJson(t *testing.T) {
|
|||||||
writer.Flush()
|
writer.Flush()
|
||||||
test.AssertResult(t, expected, output.String())
|
test.AssertResult(t, expected, output.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrinterRootUnwrap(t *testing.T) {
|
||||||
|
var output bytes.Buffer
|
||||||
|
var writer = bufio.NewWriter(&output)
|
||||||
|
printer := NewSimpleYamlPrinter(writer, YamlOutputFormat, true, false, 2, false)
|
||||||
|
node, err := getExpressionParser().ParseExpression(".")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
streamEvaluator := NewStreamEvaluator()
|
||||||
|
_, err = streamEvaluator.Evaluate("sample", strings.NewReader("'a'"), node, printer, NewYamlDecoder(ConfiguredYamlPreferences))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.Flush()
|
||||||
|
expected := `a
|
||||||
|
`
|
||||||
|
test.AssertResult(t, expected, output.String())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user