2020-11-17 22:37:42 +00:00
|
|
|
package yqlib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"bytes"
|
2021-02-02 07:17:59 +00:00
|
|
|
"container/list"
|
2020-11-17 22:37:42 +00:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mikefarah/yq/v4/test"
|
|
|
|
)
|
|
|
|
|
|
|
|
var multiDocSample = `a: banana
|
|
|
|
---
|
|
|
|
a: apple
|
|
|
|
---
|
|
|
|
a: coconut
|
|
|
|
`
|
|
|
|
|
2021-07-19 10:12:04 +00:00
|
|
|
var multiDocSampleLeadingExpected = `# go cats
|
|
|
|
---
|
|
|
|
a: banana
|
|
|
|
---
|
|
|
|
a: apple
|
|
|
|
---
|
|
|
|
# cool
|
|
|
|
a: coconut
|
|
|
|
`
|
|
|
|
|
2021-02-02 07:17:59 +00:00
|
|
|
func nodeToList(candidate *CandidateNode) *list.List {
|
|
|
|
elMap := list.New()
|
|
|
|
elMap.PushBack(candidate)
|
|
|
|
return elMap
|
|
|
|
}
|
|
|
|
|
2022-01-15 00:57:59 +00:00
|
|
|
func TestPrinterMultipleDocsInSequenceOnly(t *testing.T) {
|
2020-11-17 22:37:42 +00:00
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2020-11-17 22:37:42 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2020-11-17 22:37:42 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
el := inputs.Front()
|
2021-02-02 07:17:59 +00:00
|
|
|
sample1 := nodeToList(el.Value.(*CandidateNode))
|
2020-11-17 22:37:42 +00:00
|
|
|
|
|
|
|
el = el.Next()
|
2021-02-02 07:17:59 +00:00
|
|
|
sample2 := nodeToList(el.Value.(*CandidateNode))
|
2020-11-17 22:37:42 +00:00
|
|
|
|
|
|
|
el = el.Next()
|
2021-02-02 07:17:59 +00:00
|
|
|
sample3 := nodeToList(el.Value.(*CandidateNode))
|
2020-11-17 22:37:42 +00:00
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample1)
|
2020-11-19 11:11:26 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample2)
|
2020-11-19 11:11:26 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample3)
|
2020-11-19 11:11:26 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-17 22:37:42 +00:00
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
test.AssertResult(t, multiDocSample, output.String())
|
2020-12-15 03:33:50 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 10:12:04 +00:00
|
|
|
func TestPrinterMultipleDocsInSequenceWithLeadingContent(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2021-07-19 10:12:04 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
el := inputs.Front()
|
2023-09-18 23:52:36 +00:00
|
|
|
el.Value.(*CandidateNode).LeadingContent = "# go cats\n$yqDocSeparator$\n"
|
2021-07-19 10:12:04 +00:00
|
|
|
sample1 := nodeToList(el.Value.(*CandidateNode))
|
|
|
|
|
|
|
|
el = el.Next()
|
2023-09-18 23:52:36 +00:00
|
|
|
el.Value.(*CandidateNode).LeadingContent = "$yqDocSeparator$\n"
|
2021-07-19 10:12:04 +00:00
|
|
|
sample2 := nodeToList(el.Value.(*CandidateNode))
|
|
|
|
|
|
|
|
el = el.Next()
|
2023-09-18 23:52:36 +00:00
|
|
|
el.Value.(*CandidateNode).LeadingContent = "$yqDocSeparator$\n# cool\n"
|
2021-07-19 10:12:04 +00:00
|
|
|
sample3 := nodeToList(el.Value.(*CandidateNode))
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample1)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample2)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample3)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
|
|
|
|
test.AssertResult(t, multiDocSampleLeadingExpected, output.String())
|
|
|
|
}
|
|
|
|
|
2020-12-15 03:33:50 +00:00
|
|
|
func TestPrinterMultipleFilesInSequence(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2020-11-17 22:37:42 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2020-12-15 03:33:50 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
el := inputs.Front()
|
|
|
|
elNode := el.Value.(*CandidateNode)
|
2023-10-18 01:11:53 +00:00
|
|
|
elNode.document = 0
|
|
|
|
elNode.fileIndex = 0
|
2021-02-02 07:17:59 +00:00
|
|
|
sample1 := nodeToList(elNode)
|
2020-12-15 03:33:50 +00:00
|
|
|
|
|
|
|
el = el.Next()
|
|
|
|
elNode = el.Value.(*CandidateNode)
|
2023-10-18 01:11:53 +00:00
|
|
|
elNode.document = 0
|
|
|
|
elNode.fileIndex = 1
|
2021-02-02 07:17:59 +00:00
|
|
|
sample2 := nodeToList(elNode)
|
2020-12-15 03:33:50 +00:00
|
|
|
|
|
|
|
el = el.Next()
|
|
|
|
elNode = el.Value.(*CandidateNode)
|
2023-10-18 01:11:53 +00:00
|
|
|
elNode.document = 0
|
|
|
|
elNode.fileIndex = 2
|
2021-02-02 07:17:59 +00:00
|
|
|
sample3 := nodeToList(elNode)
|
2020-12-15 03:33:50 +00:00
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample1)
|
2020-12-15 03:33:50 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample2)
|
2020-12-15 03:33:50 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample3)
|
2020-12-15 03:33:50 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
test.AssertResult(t, multiDocSample, output.String())
|
2020-11-17 22:37:42 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 10:12:04 +00:00
|
|
|
func TestPrinterMultipleFilesInSequenceWithLeadingContent(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2021-07-19 10:12:04 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
el := inputs.Front()
|
|
|
|
elNode := el.Value.(*CandidateNode)
|
2023-10-18 01:11:53 +00:00
|
|
|
elNode.document = 0
|
|
|
|
elNode.fileIndex = 0
|
2023-09-18 23:52:36 +00:00
|
|
|
elNode.LeadingContent = "# go cats\n$yqDocSeparator$\n"
|
2021-07-19 10:12:04 +00:00
|
|
|
sample1 := nodeToList(elNode)
|
|
|
|
|
|
|
|
el = el.Next()
|
|
|
|
elNode = el.Value.(*CandidateNode)
|
2023-10-18 01:11:53 +00:00
|
|
|
elNode.document = 0
|
|
|
|
elNode.fileIndex = 1
|
2023-09-18 23:52:36 +00:00
|
|
|
elNode.LeadingContent = "$yqDocSeparator$\n"
|
2021-07-19 10:12:04 +00:00
|
|
|
sample2 := nodeToList(elNode)
|
|
|
|
|
|
|
|
el = el.Next()
|
|
|
|
elNode = el.Value.(*CandidateNode)
|
2023-10-18 01:11:53 +00:00
|
|
|
elNode.document = 0
|
|
|
|
elNode.fileIndex = 2
|
2023-09-18 23:52:36 +00:00
|
|
|
elNode.LeadingContent = "$yqDocSeparator$\n# cool\n"
|
2021-07-19 10:12:04 +00:00
|
|
|
sample3 := nodeToList(elNode)
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample1)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample2)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(sample3)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
test.AssertResult(t, multiDocSampleLeadingExpected, output.String())
|
|
|
|
}
|
|
|
|
|
2020-11-17 22:37:42 +00:00
|
|
|
func TestPrinterMultipleDocsInSinglePrint(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2020-11-17 22:37:42 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2020-11-17 22:37:42 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(inputs)
|
2020-11-19 11:11:26 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-17 22:37:42 +00:00
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
test.AssertResult(t, multiDocSample, output.String())
|
|
|
|
}
|
|
|
|
|
2021-07-19 10:12:04 +00:00
|
|
|
func TestPrinterMultipleDocsInSinglePrintWithLeadingDoc(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2021-07-19 10:12:04 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2023-09-18 23:52:36 +00:00
|
|
|
inputs.Front().Value.(*CandidateNode).LeadingContent = "# go cats\n$yqDocSeparator$\n"
|
2021-07-20 00:19:55 +00:00
|
|
|
|
|
|
|
err = printer.PrintResults(inputs)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
expected := `# go cats
|
|
|
|
---
|
|
|
|
a: banana
|
|
|
|
---
|
|
|
|
a: apple
|
|
|
|
---
|
|
|
|
a: coconut
|
|
|
|
`
|
|
|
|
test.AssertResult(t, expected, output.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPrinterMultipleDocsInSinglePrintWithLeadingDocTrailing(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2021-07-19 10:12:04 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2023-09-18 23:52:36 +00:00
|
|
|
inputs.Front().Value.(*CandidateNode).LeadingContent = "$yqDocSeparator$\n"
|
2021-07-20 00:19:55 +00:00
|
|
|
err = printer.PrintResults(inputs)
|
2021-07-19 10:12:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
expected := `---
|
|
|
|
a: banana
|
|
|
|
---
|
|
|
|
a: apple
|
|
|
|
---
|
|
|
|
a: coconut
|
|
|
|
`
|
|
|
|
test.AssertResult(t, expected, output.String())
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:18:40 +00:00
|
|
|
func TestPrinterScalarWithLeadingCont(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, true)
|
2021-07-19 23:18:40 +00:00
|
|
|
|
2022-02-01 03:47:51 +00:00
|
|
|
node, err := getExpressionParser().ParseExpression(".a")
|
2021-07-19 23:18:40 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
streamEvaluator := NewStreamEvaluator()
|
2022-10-28 03:16:46 +00:00
|
|
|
_, err = streamEvaluator.Evaluate("sample", strings.NewReader(multiDocSample), node, printer, NewYamlDecoder(ConfiguredYamlPreferences))
|
2021-07-19 23:18:40 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
expected := `banana
|
|
|
|
---
|
|
|
|
apple
|
|
|
|
---
|
|
|
|
coconut
|
|
|
|
`
|
|
|
|
test.AssertResult(t, expected, output.String())
|
|
|
|
}
|
|
|
|
|
2020-11-17 22:37:42 +00:00
|
|
|
func TestPrinterMultipleDocsJson(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2021-03-19 01:40:34 +00:00
|
|
|
// note printDocSeparators is true, it should still not print document separators
|
2023-09-18 23:52:36 +00:00
|
|
|
// when outputting JSON.
|
2024-02-24 04:59:12 +00:00
|
|
|
prefs := ConfiguredJSONPreferences.Copy()
|
2024-02-24 04:48:59 +00:00
|
|
|
prefs.Indent = 0
|
|
|
|
encoder := NewJSONEncoder(prefs)
|
2023-03-01 02:19:06 +00:00
|
|
|
if encoder == nil {
|
|
|
|
t.Skipf("no support for %s output format", "json")
|
|
|
|
}
|
|
|
|
printer := NewPrinter(encoder, NewSinglePrinterWriter(writer))
|
2020-11-17 22:37:42 +00:00
|
|
|
|
2022-10-28 03:16:46 +00:00
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
2020-11-17 22:37:42 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-11-13 23:31:37 +00:00
|
|
|
inputs.Front().Value.(*CandidateNode).LeadingContent = "# ignore this\n"
|
2021-07-20 00:19:55 +00:00
|
|
|
|
|
|
|
err = printer.PrintResults(inputs)
|
2020-11-19 11:11:26 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-17 22:37:42 +00:00
|
|
|
|
|
|
|
expected := `{"a":"banana"}
|
|
|
|
{"a":"apple"}
|
|
|
|
{"a":"coconut"}
|
|
|
|
`
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
test.AssertResult(t, expected, output.String())
|
|
|
|
}
|
2023-03-28 22:51:55 +00:00
|
|
|
|
|
|
|
func TestPrinterNulSeparator(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, false)
|
2023-03-28 22:51:55 +00:00
|
|
|
printer.SetNulSepOutput(true)
|
|
|
|
node, err := getExpressionParser().ParseExpression(".a")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
streamEvaluator := NewStreamEvaluator()
|
|
|
|
_, err = streamEvaluator.Evaluate("sample", strings.NewReader(multiDocSample), node, printer, NewYamlDecoder(ConfiguredYamlPreferences))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
expected := "banana\x00apple\x00coconut\x00"
|
|
|
|
test.AssertResult(t, expected, output.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPrinterNulSeparatorWithJson(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
|
|
|
// note printDocSeparators is true, it should still not print document separators
|
2023-09-18 23:52:36 +00:00
|
|
|
// when outputting JSON.
|
2024-02-24 04:59:12 +00:00
|
|
|
prefs := ConfiguredJSONPreferences.Copy()
|
2024-02-24 04:48:59 +00:00
|
|
|
prefs.Indent = 0
|
|
|
|
encoder := NewJSONEncoder(prefs)
|
2023-03-28 22:51:55 +00:00
|
|
|
if encoder == nil {
|
|
|
|
t.Skipf("no support for %s output format", "json")
|
|
|
|
}
|
|
|
|
printer := NewPrinter(encoder, NewSinglePrinterWriter(writer))
|
|
|
|
printer.SetNulSepOutput(true)
|
|
|
|
|
|
|
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
inputs.Front().Value.(*CandidateNode).LeadingContent = "# ignore this\n"
|
|
|
|
|
|
|
|
err = printer.PrintResults(inputs)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
expected := `{"a":"banana"}` + "\x00" + `{"a":"apple"}` + "\x00" + `{"a":"coconut"}` + "\x00"
|
|
|
|
|
|
|
|
writer.Flush()
|
|
|
|
test.AssertResult(t, expected, output.String())
|
|
|
|
}
|
2023-10-23 09:03:51 +00:00
|
|
|
|
|
|
|
func TestPrinterRootUnwrap(t *testing.T) {
|
|
|
|
var output bytes.Buffer
|
|
|
|
var writer = bufio.NewWriter(&output)
|
2024-02-24 04:36:16 +00:00
|
|
|
printer := NewSimpleYamlPrinter(writer, true, 2, false)
|
2023-10-23 09:03:51 +00:00
|
|
|
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()
|
2023-11-07 22:09:21 +00:00
|
|
|
expected := `a
|
2023-10-23 09:03:51 +00:00
|
|
|
`
|
|
|
|
test.AssertResult(t, expected, output.String())
|
|
|
|
}
|