planetmint-go/x/dao/keeper/query_get_reissuance_test.go
Julian Strobl 5b25d4cefc
Improve linter setup (#186)
* [linter] Add `musttag`

Enforce field tags in (un)marshaled structs.

* [linter] Add `nestif`

Reports deeply nested if statements.

* [linter] Add `noctx`

Finds sending http request without context.Context.

* [linter] Add `paralleltest`

Paralleltest detects missing usage of t.Parallel() method in your Go
test.

* [linter] Add `tagalign`

Check that struct tags are well aligned.

* [linter] Add `tagliatelle`

Checks the struct tags.

* [linter] Add `whitespace`

Tool for detection of leading and trailing whitespace.

* [paralleltest] Exclude files bc of data race in tests

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-17 10:56:25 +01:00

49 lines
1.2 KiB
Go

package keeper_test
import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
"github.com/planetmint/planetmint-go/x/dao/types"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func TestQueryGetReissuance(t *testing.T) {
t.Parallel()
keeper, ctx := keepertest.DaoKeeper(t)
wctx := sdk.WrapSDKContext(ctx)
items := createNReissuances(keeper, ctx, 1)
for _, tc := range []struct {
desc string
request *types.QueryGetReissuanceRequest
response *types.QueryGetReissuanceResponse
err error
}{
{
desc: "reissuance request found",
request: &types.QueryGetReissuanceRequest{BlockHeight: 0},
response: &types.QueryGetReissuanceResponse{Reissuance: &items[0]},
},
{
desc: "reissuance request not found",
request: &types.QueryGetReissuanceRequest{BlockHeight: 100},
err: status.Error(codes.NotFound, "reissuance not found"),
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
res, err := keeper.GetReissuance(wctx, tc.request)
if tc.err != nil {
require.ErrorIs(t, err, tc.err)
} else {
require.Equal(t, tc.response, res)
}
})
}
}