R4R: Ensure all CLI queries respect output flags (#3320)

This commit is contained in:
Jack Zampolin
2019-01-22 09:28:39 -08:00
committed by GitHub
parent b055c129dd
commit 9f50c9f5b6
30 changed files with 739 additions and 708 deletions
+5 -5
View File
@@ -383,7 +383,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom).Int64())
proposalsQuery := f.QueryGovProposals()
require.Equal(t, "No matching proposals found", proposalsQuery)
require.Empty(t, proposalsQuery)
// Test submit generate only for submit proposal
success, stdout, stderr := f.TxGovSubmitProposal(
@@ -418,7 +418,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
// Ensure query proposals returns properly
proposalsQuery = f.QueryGovProposals()
require.Equal(t, " 1 - Test", proposalsQuery)
require.Equal(t, uint64(1), proposalsQuery[0].GetProposalID())
// Query the deposits on the proposal
deposit := f.QueryGovDeposit(1, fooAddr)
@@ -489,11 +489,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
// Ensure no proposals in deposit period
proposalsQuery = f.QueryGovProposals("--status=DepositPeriod")
require.Equal(t, "No matching proposals found", proposalsQuery)
require.Empty(t, proposalsQuery)
// Ensure the proposal returns as in the voting period
proposalsQuery = f.QueryGovProposals("--status=VotingPeriod")
require.Equal(t, " 1 - Test", proposalsQuery)
require.Equal(t, uint64(1), proposalsQuery[0].GetProposalID())
// submit a second test proposal
f.TxGovSubmitProposal(keyFoo, "Text", "Apples", "test", sdk.NewInt64Coin(denom, 5))
@@ -501,7 +501,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
// Test limit on proposals query
proposalsQuery = f.QueryGovProposals("--limit=1")
require.Equal(t, " 2 - Apples", proposalsQuery)
require.Equal(t, uint64(2), proposalsQuery[0].GetProposalID())
f.Cleanup()
}
+10 -3
View File
@@ -380,7 +380,7 @@ func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool {
// QueryStakingParameters is gaiacli query staking parameters
func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params {
cmd := fmt.Sprintf("gaiacli query staking parameters %v", f.Flags())
cmd := fmt.Sprintf("gaiacli query staking params %v", f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var params staking.Params
cdc := app.MakeCodec()
@@ -426,11 +426,18 @@ func (f *Fixtures) QueryGovParamTallying() gov.TallyParams {
}
// QueryGovProposals is gaiacli query gov proposals
func (f *Fixtures) QueryGovProposals(flags ...string) string {
func (f *Fixtures) QueryGovProposals(flags ...string) gov.Proposals {
cmd := fmt.Sprintf("gaiacli query gov proposals %v", f.Flags())
stdout, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
if strings.Contains(stderr, "No matching proposals found") {
return gov.Proposals{}
}
require.Empty(f.T, stderr)
return stdout
var out gov.Proposals
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(stdout), &out)
require.NoError(f.T, err)
return out
}
// QueryGovProposal is gaiacli query gov proposal