add test for key order

This commit is contained in:
Morgan Bazalgette
2020-10-09 08:38:42 +11:00
committed by Mike Farah
parent bb9cb0c60e
commit 996ee0b433
+20
View File
@@ -1441,3 +1441,23 @@ func TestReadFindValueDeepObjectCmd(t *testing.T) {
`
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)
}