forked from cerc-io/laconicd
Prathamesh Musale
d346b95234
- Add E2E tests following pattern suggested in cosmos-sdk docs: https://docs.cosmos.network/v0.50/build/building-modules/testing#end-to-end-tests - Tests for gRPC requests - Tests for manually configured CLI commands - Add a CI workflow to run these E2E tests Reviewed-on: deep-stack/laconic2d#13 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package bond
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
|
|
|
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
|
"git.vdb.to/cerc-io/laconic2d/x/bond/client/cli"
|
|
)
|
|
|
|
func (ets *E2ETestSuite) TestGetQueryBondList() {
|
|
val := ets.network.Validators[0]
|
|
sr := ets.Require()
|
|
|
|
testCases := []struct {
|
|
name string
|
|
args []string
|
|
createBond bool
|
|
preRun func()
|
|
}{
|
|
{
|
|
"create and get bond lists",
|
|
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
|
true,
|
|
func() {
|
|
ets.createBond()
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
ets.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
|
clientCtx := val.ClientCtx
|
|
if tc.createBond {
|
|
tc.preRun()
|
|
}
|
|
|
|
cmd := cli.GetQueryBondList()
|
|
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
|
sr.NoError(err)
|
|
var queryResponse bondtypes.QueryGetBondsResponse
|
|
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), &queryResponse)
|
|
sr.NoError(err)
|
|
sr.NotZero(len(queryResponse.GetBonds()))
|
|
})
|
|
}
|
|
}
|