planetmint-go/x/asset/keeper/query_get_notarized_asset_test.go
Jürgen Eckel 8fd9f213f3
77 rename asset hash to asset cid (#97)
* initial asset notarization restructuring
* adjusted test cases, two are still failing
* removed obsolete data structures

---------

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-09-27 16:35:31 +02:00

47 lines
1.2 KiB
Go

package keeper_test
import (
"testing"
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
"github.com/planetmint/planetmint-go/x/asset/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
)
func TestGetNotarizedAsset(t *testing.T) {
keeper, ctx := keepertest.AssetKeeper(t)
wctx := sdk.WrapSDKContext(ctx)
msgs := createNAsset(keeper, ctx, 1)
for _, tc := range []struct {
desc string
request *types.QueryGetNotarizedAssetRequest
response *types.QueryGetNotarizedAssetResponse
err error
}{
{
desc: "cid found",
request: &types.QueryGetNotarizedAssetRequest{Cid: msgs[0].GetCid()},
response: &types.QueryGetNotarizedAssetResponse{Cid: msgs[0].GetCid()},
},
{
desc: "cid not found",
request: &types.QueryGetNotarizedAssetRequest{Cid: "invalid key"},
err: status.Error(codes.NotFound, "cid not found"),
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
response, err := keeper.GetNotarizedAsset(wctx, tc.request)
if tc.err != nil {
require.ErrorIs(t, err, tc.err)
} else {
require.Equal(t, tc.response, response)
}
})
}
}