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>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package auction
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
|
|
|
types "git.vdb.to/cerc-io/laconic2d/x/auction"
|
|
"git.vdb.to/cerc-io/laconic2d/x/auction/client/cli"
|
|
)
|
|
|
|
var queryJSONFlag = []string{fmt.Sprintf("--%s=json", flags.FlagOutput)}
|
|
|
|
func (ets *E2ETestSuite) TestGetCmdList() {
|
|
val := ets.network.Validators[0]
|
|
sr := ets.Require()
|
|
|
|
testCases := []struct {
|
|
msg string
|
|
createAuction bool
|
|
}{
|
|
{
|
|
"list auctions when no auctions exist",
|
|
false,
|
|
},
|
|
{
|
|
"list auctions after creating an auction",
|
|
true,
|
|
},
|
|
}
|
|
|
|
for _, test := range testCases {
|
|
ets.Run(fmt.Sprintf("Case %s", test.msg), func() {
|
|
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdList(), queryJSONFlag)
|
|
sr.NoError(err)
|
|
var auctions types.QueryAuctionsResponse
|
|
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &auctions)
|
|
sr.NoError(err)
|
|
if test.createAuction {
|
|
sr.NotZero(len(auctions.Auctions.Auctions))
|
|
}
|
|
})
|
|
}
|
|
}
|