package masterservice import ( "testing" "github.com/stretchr/testify/assert" "github.com/zilliztech/milvus-distributed/internal/proto/commonpb" "github.com/zilliztech/milvus-distributed/internal/proto/etcdpb" "github.com/zilliztech/milvus-distributed/internal/proto/schemapb" ) func TestEqualKeyPairArray(t *testing.T) { p1 := []*commonpb.KeyValuePair{ { Key: "k1", Value: "v1", }, } p2 := []*commonpb.KeyValuePair{} assert.False(t, EqualKeyPairArray(p1, p2)) p2 = append(p2, &commonpb.KeyValuePair{ Key: "k2", Value: "v2", }) assert.False(t, EqualKeyPairArray(p1, p2)) p2 = []*commonpb.KeyValuePair{ { Key: "k1", Value: "v2", }, } assert.False(t, EqualKeyPairArray(p1, p2)) p2 = []*commonpb.KeyValuePair{ { Key: "k1", Value: "v1", }, } assert.True(t, EqualKeyPairArray(p1, p2)) } func Test_GetFieldSchemaByID(t *testing.T) { coll := &etcdpb.CollectionInfo{ Schema: &schemapb.CollectionSchema{ Fields: []*schemapb.FieldSchema{ { FieldID: 1, }, }, }, } _, err := GetFieldSchemaByID(coll, 1) assert.Nil(t, err) _, err = GetFieldSchemaByID(coll, 2) assert.NotNil(t, err) }