cosmos-sdk/tests/e2e/gov/query.go
2023-07-14 09:07:50 +00:00

57 lines
1.1 KiB
Go

package gov
import (
"fmt"
"strings"
"github.com/cosmos/cosmos-sdk/client/flags"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
)
func (s *E2ETestSuite) TestCmdProposer() {
val := s.network.Validators[0]
testCases := []struct {
name string
args []string
expectErr bool
expectedOutput string
}{
{
"without proposal id",
[]string{
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
true,
``,
},
{
"json output",
[]string{
"1",
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
false,
fmt.Sprintf("{\"proposal_id\":\"%s\",\"proposer\":\"%s\"}", "1", val.Address.String()),
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.GetCmdQueryProposer()
clientCtx := val.ClientCtx
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Error(err)
} else {
s.Require().NoError(err)
s.Require().Equal(strings.TrimSpace(tc.expectedOutput), strings.TrimSpace(out.String()))
}
})
}
}