50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
|
package keeper_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||
|
"github.com/stretchr/testify/require"
|
||
|
"google.golang.org/grpc/codes"
|
||
|
"google.golang.org/grpc/status"
|
||
|
|
||
|
keepertest "cosmos-test/testutil/keeper"
|
||
|
"cosmos-test/testutil/nullify"
|
||
|
"cosmos-test/x/cosmostest/types"
|
||
|
)
|
||
|
|
||
|
func TestNextAuctionQuery(t *testing.T) {
|
||
|
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||
|
wctx := sdk.WrapSDKContext(ctx)
|
||
|
item := createTestNextAuction(keeper, ctx)
|
||
|
for _, tc := range []struct {
|
||
|
desc string
|
||
|
request *types.QueryGetNextAuctionRequest
|
||
|
response *types.QueryGetNextAuctionResponse
|
||
|
err error
|
||
|
}{
|
||
|
{
|
||
|
desc: "First",
|
||
|
request: &types.QueryGetNextAuctionRequest{},
|
||
|
response: &types.QueryGetNextAuctionResponse{NextAuction: item},
|
||
|
},
|
||
|
{
|
||
|
desc: "InvalidRequest",
|
||
|
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||
|
},
|
||
|
} {
|
||
|
t.Run(tc.desc, func(t *testing.T) {
|
||
|
response, err := keeper.NextAuction(wctx, tc.request)
|
||
|
if tc.err != nil {
|
||
|
require.ErrorIs(t, err, tc.err)
|
||
|
} else {
|
||
|
require.NoError(t, err)
|
||
|
require.Equal(t,
|
||
|
nullify.Fill(tc.response),
|
||
|
nullify.Fill(response),
|
||
|
)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|