yq/pkg/yqlib/goccy_yaml_test.go

69 lines
1.3 KiB
Go
Raw Normal View History

2023-10-05 06:53:42 +00:00
package yqlib
import (
"testing"
"github.com/mikefarah/yq/v4/test"
)
var goccyYamlFormatScenarios = []formatScenario{
2023-10-05 07:04:11 +00:00
{
description: "basic - 3",
skipDoc: true,
input: "3",
expected: "3\n",
},
{
description: "basic - 3.1",
skipDoc: true,
input: "3.1",
expected: "3.1\n",
},
{
description: "basic - 3.1",
skipDoc: true,
input: "mike: 3",
expected: "mike: 3\n",
},
{
description: "basic - 3.1",
skipDoc: true,
input: "{mike: 3}",
expected: "{mike: 3}\n",
},
{
description: "basic - 3.1",
skipDoc: true,
input: "{\nmike: 3\n}",
expected: "{mike: 3}\n",
},
2023-10-05 06:53:42 +00:00
{
description: "basic - 3.1",
skipDoc: true,
input: "mike: !!cat 3",
expected: "mike: !!cat 3\n",
},
2023-10-05 07:04:11 +00:00
{
description: "basic - 3.1",
skipDoc: true,
input: "- 3",
expected: "- 3\n",
},
{
description: "basic - 3.1",
skipDoc: true,
input: "[3]",
expected: "[3]\n",
},
2023-10-05 06:53:42 +00:00
}
func testGoccyYamlScenario(t *testing.T, s formatScenario) {
test.AssertResultWithContext(t, s.expected, mustProcessFormatScenario(s, NewGoccyYAMLDecoder(), NewYamlEncoder(2, false, ConfiguredYamlPreferences)), s.description)
}
func TestGoccyYmlFormatScenarios(t *testing.T) {
for _, tt := range goccyYamlFormatScenarios {
testGoccyYamlScenario(t, tt)
}
}