mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-14 15:18:06 +00:00
53 lines
1.0 KiB
Go
53 lines
1.0 KiB
Go
|
package marshal
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/mikefarah/yq/test"
|
||
|
)
|
||
|
|
||
|
func TestYamlToString(t *testing.T) {
|
||
|
var raw = `b:
|
||
|
c: 2
|
||
|
`
|
||
|
var data = test.ParseData(raw)
|
||
|
got, _ := NewYamlConverter().YamlToString(data, false)
|
||
|
test.AssertResult(t, raw, got)
|
||
|
}
|
||
|
|
||
|
func TestYamlToString_withTrim(t *testing.T) {
|
||
|
var raw = `b:
|
||
|
c: 2`
|
||
|
var data = test.ParseData(raw)
|
||
|
got, _ := NewYamlConverter().YamlToString(data, true)
|
||
|
test.AssertResult(t, raw, got)
|
||
|
}
|
||
|
|
||
|
func TestYamlToString_withIntKey(t *testing.T) {
|
||
|
var raw = `b:
|
||
|
2: c
|
||
|
`
|
||
|
var data = test.ParseData(raw)
|
||
|
got, _ := NewYamlConverter().YamlToString(data, false)
|
||
|
test.AssertResult(t, raw, got)
|
||
|
}
|
||
|
|
||
|
func TestYamlToString_withBoolKey(t *testing.T) {
|
||
|
var raw = `b:
|
||
|
false: c
|
||
|
`
|
||
|
var data = test.ParseData(raw)
|
||
|
got, _ := NewYamlConverter().YamlToString(data, false)
|
||
|
test.AssertResult(t, raw, got)
|
||
|
}
|
||
|
|
||
|
func TestYamlToString_withArray(t *testing.T) {
|
||
|
var raw = `b:
|
||
|
- item: one
|
||
|
- item: two
|
||
|
`
|
||
|
var data = test.ParseData(raw)
|
||
|
got, _ := NewYamlConverter().YamlToString(data, false)
|
||
|
test.AssertResult(t, raw, got)
|
||
|
}
|