mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 21:09:06 +08:00
9672eae62c
Signed-off-by: yun.zhang <yun.zhang@zilliz.com>
57 lines
1.4 KiB
Go
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))
|
|
}
|