-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5085587
commit f607b10
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package cli_test | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" | ||
testnet "github.com/cosmos/cosmos-sdk/testutil/network" | ||
"github.com/cosmos/cosmos-sdk/x/evidence/client/cli" | ||
) | ||
|
||
type IntegrationTestSuite struct { | ||
suite.Suite | ||
|
||
cfg testnet.Config | ||
network *testnet.Network | ||
} | ||
|
||
func (s *IntegrationTestSuite) SetupSuite() { | ||
s.T().Log("setting up integration test suite") | ||
|
||
cfg := testnet.DefaultConfig() | ||
cfg.NumValidators = 1 | ||
|
||
s.cfg = cfg | ||
s.network = testnet.New(s.T(), 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 TestIntegrationTestSuite(t *testing.T) { | ||
suite.Run(t, new(IntegrationTestSuite)) | ||
} | ||
|
||
func (s *IntegrationTestSuite) TestGetQueryCmd() { | ||
val := s.network.Validators[0] | ||
|
||
testCases := map[string]struct { | ||
args []string | ||
expectedOutput string | ||
expectErr bool | ||
}{ | ||
"non-existant evidence": { | ||
[]string{"DF0C23E8634E480F84B9D5674A7CDC9816466DEC28A3358F73260F68D28D7660"}, | ||
"evidence DF0C23E8634E480F84B9D5674A7CDC9816466DEC28A3358F73260F68D28D7660 not found", | ||
true, | ||
}, | ||
"all evidence (default pagination)": { | ||
[]string{}, | ||
"evidence: []\npagination:\n next_key: null\n total: \"0\"", | ||
false, | ||
}, | ||
} | ||
|
||
for name, tc := range testCases { | ||
tc := tc | ||
|
||
s.Run(name, func() { | ||
cmd := cli.GetQueryCmd() | ||
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().Contains(strings.TrimSpace(out.String()), tc.expectedOutput) | ||
}) | ||
} | ||
} |