mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-13 20:15:57 +00:00
add test for key order
This commit is contained in:
parent
bb9cb0c60e
commit
996ee0b433
@ -1441,3 +1441,23 @@ func TestReadFindValueDeepObjectCmd(t *testing.T) {
|
|||||||
`
|
`
|
||||||
test.AssertResult(t, expectedOutput, result.Output)
|
test.AssertResult(t, expectedOutput, result.Output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadKeepsKeyOrderInJson(t *testing.T) {
|
||||||
|
const content = `{
|
||||||
|
"z": "One",
|
||||||
|
"a": 1,
|
||||||
|
"w": ["a", "r"],
|
||||||
|
"u": {"d": "o", "0": 11.5},
|
||||||
|
}`
|
||||||
|
filename := test.WriteTempYamlFile(content)
|
||||||
|
defer test.RemoveTempYamlFile(filename)
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := test.RunCmd(cmd, fmt.Sprintf("r -j %s", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedOutput := `{"z":"One","a":1,"w":["a","r"],"u":{"d":"o","0":11.5}}
|
||||||
|
`
|
||||||
|
test.AssertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user