github.com/Finschia/finschia-sdk@v0.48.1/x/params/client/testutil/suite.go (about) 1 package testutil 2 3 import ( 4 "fmt" 5 "strings" 6 7 ostcli "github.com/Finschia/ostracon/libs/cli" 8 "github.com/stretchr/testify/suite" 9 10 clitestutil "github.com/Finschia/finschia-sdk/testutil/cli" 11 "github.com/Finschia/finschia-sdk/testutil/network" 12 "github.com/Finschia/finschia-sdk/x/params/client/cli" 13 ) 14 15 type IntegrationTestSuite struct { 16 suite.Suite 17 18 cfg network.Config 19 network *network.Network 20 } 21 22 func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { 23 return &IntegrationTestSuite{cfg: cfg} 24 } 25 26 func (s *IntegrationTestSuite) SetupSuite() { 27 s.T().Log("setting up integration test suite") 28 29 s.network = network.New(s.T(), s.cfg) 30 31 _, err := s.network.WaitForHeight(1) 32 s.Require().NoError(err) 33 } 34 35 func (s *IntegrationTestSuite) TearDownSuite() { 36 s.T().Log("tearing down integration test suite") 37 s.network.Cleanup() 38 } 39 40 func (s *IntegrationTestSuite) TestNewQuerySubspaceParamsCmd() { 41 val := s.network.Validators[0] 42 43 testCases := []struct { 44 name string 45 args []string 46 expectedOutput string 47 }{ 48 { 49 "json output", 50 []string{ 51 "staking", "MaxValidators", 52 fmt.Sprintf("--%s=json", ostcli.OutputFlag), 53 }, 54 `{"subspace":"staking","key":"MaxValidators","value":"100"}`, 55 }, 56 { 57 "text output", 58 []string{ 59 "staking", "MaxValidators", 60 fmt.Sprintf("--%s=text", ostcli.OutputFlag), 61 }, 62 `key: MaxValidators 63 subspace: staking 64 value: "100"`, 65 }, 66 } 67 68 for _, tc := range testCases { 69 tc := tc 70 71 s.Run(tc.name, func() { 72 cmd := cli.NewQuerySubspaceParamsCmd() 73 clientCtx := val.ClientCtx 74 75 out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) 76 s.Require().NoError(err) 77 s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String())) 78 }) 79 } 80 }