Skip to content

Commit

Permalink
refactor: migrate e2e/evidence away from testify suite (cosmos#14553)
Browse files Browse the repository at this point in the history
  • Loading branch information
samricotta authored and 0xmuralik committed Jan 12, 2023
1 parent 9634364 commit c6f3d03
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 80 deletions.
66 changes: 62 additions & 4 deletions tests/e2e/evidence/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,74 @@
package evidence

import (
"strings"
"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) *fixture {
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 := f.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

t.Run(name, func(t *testing.T) {
cmd := cli.GetQueryCmd()
clientCtx := val.ClientCtx

out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
assert.Assert(t, err != nil)
} else {
assert.NilError(t, err)
}

assert.Assert(t, strings.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 c6f3d03

Please sign in to comment.