Skip to content

Commit

Permalink
refactor: migrate e2e/evidence away from testify suite
Browse files Browse the repository at this point in the history
  • Loading branch information
samricotta committed Jan 9, 2023
1 parent e9bf5b7 commit 7df36d2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 80 deletions.
65 changes: 61 additions & 4 deletions tests/e2e/evidence/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,71 @@ package evidence
import (
"testing"

"github.com/stretchr/testify/suite"

"cosmossdk.io/simapp"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/x/evidence/client/cli"
"gotest.tools/v3/assert"
)

func TestE2ETestSuite(t *testing.T) {
type fixture struct {
cfg network.Config
network *network.Network
}

func initFixture(t *testing.T) {
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, NewE2ETestSuite(cfg))

network, err := network.New(t, t.TempDir(), cfg)
assert.NilError(t, err)
assert.NilError(t, network.WaitForNextBlock())

return &fixture{
cfg: cfg,
network: network,
}
}

func TestGetQueryCmd(t *testing.T) {
t.Parallel()
f := initFixture(t)
defer f.network.Cleanup()

val := s.network.Validators[0]

testCases := map[string]struct {
args []string
expectedOutput string
expectErr bool
}{
"non-existent 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(t. *testing.T) {
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)
})
}
}
76 changes: 0 additions & 76 deletions tests/e2e/evidence/suite.go

This file was deleted.

0 comments on commit 7df36d2

Please sign in to comment.