mukan-ignite/ignite/templates/field/field_test.go
Mukan Erkin Törük 26b204bd04
Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

89 lines
1.9 KiB
Go

package field
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/ignite/cli/v29/ignite/pkg/multiformatname"
"github.com/ignite/cli/v29/ignite/templates/field/datatype"
)
// TestField_IsSlice tests the IsSlice method of Field struct.
func TestField_IsSlice(t *testing.T) {
testCases := []struct {
name string
field Field
expected bool
}{
{
name: "array type should be slice",
field: Field{
Name: multiformatname.Name{},
DatatypeName: datatype.IntSlice,
Datatype: string(datatype.IntSlice),
},
expected: true,
},
{
name: "array type should be slice",
field: Field{
Name: multiformatname.Name{},
DatatypeName: datatype.Bytes,
Datatype: string(datatype.Bytes),
},
expected: true,
},
{
name: "array type should be slice",
field: Field{
Name: multiformatname.Name{},
DatatypeName: datatype.CoinSliceAlias,
Datatype: string(datatype.CoinSliceAlias),
},
expected: true,
},
{
name: "coin type should not be slice",
field: Field{
Name: multiformatname.Name{},
DatatypeName: datatype.Coin,
Datatype: string(datatype.Coin),
},
expected: false,
},
{
name: "string type should not be slice",
field: Field{
Name: multiformatname.Name{},
DatatypeName: datatype.String,
Datatype: "",
},
expected: false,
},
{
name: "int type should not be slice",
field: Field{
Name: multiformatname.Name{},
DatatypeName: datatype.Int,
Datatype: "",
},
expected: false,
},
{
name: "custom array type should be slice",
field: Field{
Name: multiformatname.Name{},
DatatypeName: datatype.CustomSlice,
Datatype: "Bar",
},
expected: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
require.Equal(t, tc.expected, tc.field.IsSlice())
})
}
}