laconicd/tests/e2e/auction/query.go

46 lines
1.0 KiB
Go
Raw Normal View History

2024-03-01 09:51:36 +00:00
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))
}
})
}
}