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