yq/pkg/yqlib/yaml_test.go
Mike Farah 27fa4e10b8 wip
2023-04-13 14:44:39 +10:00

63 lines
1.2 KiB
Go

package yqlib
import (
"testing"
"github.com/mikefarah/yq/v4/test"
)
var yamlScenarios = []formatScenario{
{
description: "basic - null",
skipDoc: true,
input: "null",
expected: "null\n",
},
// {
// description: "basic - ~",
// skipDoc: true,
// input: "~",
// expected: "~\n",
// },
{
description: "basic - [null]",
skipDoc: true,
input: "[null]",
expected: "[null]\n",
},
{
description: "basic - [~]",
skipDoc: true,
input: "[~]",
expected: "[~]\n",
},
{
description: "basic - null map value",
skipDoc: true,
input: "a: null",
expected: "a: null\n",
},
{
description: "basic - number",
skipDoc: true,
input: "3",
expected: "3\n",
},
{
description: "basic - float",
skipDoc: true,
input: "3.1",
expected: "3.1\n",
},
}
func testYamlScenario(t *testing.T, s formatScenario) {
test.AssertResultWithContext(t, s.expected, mustProcessFormatScenario(s, NewYamlDecoder(ConfiguredYamlPreferences), NewYamlEncoder(2, false, ConfiguredYamlPreferences)), s.description)
}
func TestYamlScenarios(t *testing.T) {
for _, tt := range yamlScenarios {
testYamlScenario(t, tt)
}
}