mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-05-22 14:56:39 +00:00

This is the quasi-standard and fixes the error below: ``` $ go get -u github.com/planetmint/planetmint-go@v0.1.0 go: github.com/planetmint/planetmint-go@v0.1.0: parsing go.mod: module declares its path as: planetmint-go but was required as: github.com/planetmint/planetmint-go ``` Signed-off-by: Julian Strobl <jmastr@mailbox.org>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package keeper_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
|
"github.com/planetmint/planetmint-go/x/machine/keeper"
|
|
"github.com/planetmint/planetmint-go/x/machine/types"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func createNMachine(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Machine {
|
|
items := make([]types.Machine, n)
|
|
for i := range items {
|
|
items[i].MachineId = fmt.Sprintf("machineId%v", i)
|
|
items[i].IssuerPlanetmint = fmt.Sprintf("issuerPlanetmint%v", i)
|
|
items[i].IssuerLiquid = fmt.Sprintf("issuerLiquid%v", i)
|
|
keeper.StoreMachine(ctx, items[i])
|
|
keeper.StoreMachineIndex(ctx, items[i])
|
|
}
|
|
return items
|
|
}
|
|
|
|
func TestGetMachine(t *testing.T) {
|
|
keeper, ctx := keepertest.MachineKeeper(t)
|
|
items := createNMachine(keeper, ctx, 10)
|
|
for _, item := range items {
|
|
index := types.MachineIndex{
|
|
MachineId: item.MachineId,
|
|
IssuerPlanetmint: item.IssuerPlanetmint,
|
|
IssuerLiquid: item.IssuerLiquid,
|
|
}
|
|
machineById, found := keeper.GetMachine(ctx, index)
|
|
assert.True(t, found)
|
|
assert.Equal(t, item, machineById)
|
|
}
|
|
}
|
|
|
|
func TestGetMachineIndex(t *testing.T) {
|
|
keeper, ctx := keepertest.MachineKeeper(t)
|
|
items := createNMachine(keeper, ctx, 10)
|
|
for _, item := range items {
|
|
expectedIndex := types.MachineIndex{
|
|
MachineId: item.MachineId,
|
|
IssuerPlanetmint: item.IssuerPlanetmint,
|
|
IssuerLiquid: item.IssuerLiquid,
|
|
}
|
|
index, found := keeper.GetMachineIndex(ctx, item.MachineId)
|
|
assert.True(t, found)
|
|
assert.Equal(t, expectedIndex, index)
|
|
}
|
|
}
|