milvus/internal/metastore/model/field_test.go
jaime 9672eae62c
Unify metastore catalog interface (#17772)
Signed-off-by: yun.zhang <yun.zhang@zilliz.com>
2022-07-22 10:20:29 +08:00

57 lines
1.4 KiB
Go

package model
import (
"testing"
"github.com/milvus-io/milvus/internal/proto/schemapb"
"github.com/stretchr/testify/assert"
)
var (
filedSchemaPb = &schemapb.FieldSchema{
FieldID: fieldID,
Name: fieldName,
IsPrimaryKey: false,
Description: "none",
DataType: schemapb.DataType_FloatVector,
TypeParams: typeParams,
IndexParams: indexParams,
AutoID: false,
}
fieldModel = &Field{
FieldID: fieldID,
Name: fieldName,
IsPrimaryKey: false,
Description: "none",
AutoID: false,
DataType: schemapb.DataType_FloatVector,
TypeParams: typeParams,
IndexParams: indexParams,
}
)
func TestMarshalFieldModel(t *testing.T) {
ret := MarshalFieldModel(fieldModel)
assert.Equal(t, filedSchemaPb, ret)
assert.Nil(t, MarshalFieldModel(nil))
}
func TestMarshalFieldModels(t *testing.T) {
ret := MarshalFieldModels([]*Field{fieldModel})
assert.Equal(t, []*schemapb.FieldSchema{filedSchemaPb}, ret)
assert.Nil(t, MarshalFieldModels(nil))
}
func TestUnmarshalFieldModel(t *testing.T) {
ret := UnmarshalFieldModel(filedSchemaPb)
assert.Equal(t, fieldModel, ret)
assert.Nil(t, UnmarshalFieldModel(nil))
}
func TestUnmarshalFieldModels(t *testing.T) {
ret := UnmarshalFieldModels([]*schemapb.FieldSchema{filedSchemaPb})
assert.Equal(t, []*Field{fieldModel}, ret)
assert.Nil(t, UnmarshalFieldModels(nil))
}