Merge PR #6525: x/bank: Refactor CLI & Tests
This commit is contained in:
@@ -106,36 +106,16 @@ func TestContext_PrintOutput(t *testing.T) {
|
||||
buf := &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = "json"
|
||||
ctx.Indent = false
|
||||
err = ctx.PrintOutput(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
`{"animal":{"@type":"/cosmos_sdk.codec.v1.Dog","size":"big","name":"Spot"},"x":"10"}
|
||||
`, string(buf.Bytes()))
|
||||
|
||||
// json indent
|
||||
buf = &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = "json"
|
||||
ctx.Indent = true
|
||||
err = ctx.PrintOutput(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
`{
|
||||
"animal": {
|
||||
"@type": "/cosmos_sdk.codec.v1.Dog",
|
||||
"name": "Spot",
|
||||
"size": "big"
|
||||
},
|
||||
"x": "10"
|
||||
}
|
||||
`, string(buf.Bytes()))
|
||||
|
||||
// yaml
|
||||
buf = &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = "text"
|
||||
ctx.Indent = false
|
||||
err = ctx.PrintOutput(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
@@ -156,41 +136,16 @@ x: "10"
|
||||
buf = &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = "json"
|
||||
ctx.Indent = false
|
||||
err = ctx.PrintOutput(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
`{"type":"testdata/HasAnimal","value":{"animal":{"type":"testdata/Dog","value":{"size":"big","name":"Spot"}},"x":"10"}}
|
||||
`, string(buf.Bytes()))
|
||||
|
||||
// json indent
|
||||
buf = &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = "json"
|
||||
ctx.Indent = true
|
||||
err = ctx.PrintOutput(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
`{
|
||||
"type": "testdata/HasAnimal",
|
||||
"value": {
|
||||
"animal": {
|
||||
"type": "testdata/Dog",
|
||||
"value": {
|
||||
"name": "Spot",
|
||||
"size": "big"
|
||||
}
|
||||
},
|
||||
"x": "10"
|
||||
}
|
||||
}
|
||||
`, string(buf.Bytes()))
|
||||
|
||||
// yaml
|
||||
buf = &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = "text"
|
||||
ctx.Indent = false
|
||||
err = ctx.PrintOutput(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
|
||||
Reference in New Issue
Block a user