github.com/weaviate/weaviate@v1.24.6/entities/schema/test_utils/nested_properties.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package test_utils 13 14 import ( 15 "testing" 16 17 "github.com/stretchr/testify/assert" 18 "github.com/stretchr/testify/require" 19 "github.com/weaviate/weaviate/entities/models" 20 "github.com/weaviate/weaviate/entities/schema" 21 ) 22 23 func AssertNestedPropsMatch(t *testing.T, nestedPropsA, nestedPropsB []*models.NestedProperty) { 24 require.Len(t, nestedPropsB, len(nestedPropsA), "nestedProps: different length") 25 26 npMap := map[string]int{} 27 for index, np := range nestedPropsA { 28 npMap[np.Name] = index 29 } 30 31 for _, npB := range nestedPropsB { 32 require.Contains(t, npMap, npB.Name) 33 npA := nestedPropsA[npMap[npB.Name]] 34 35 assert.Equal(t, npA.DataType, npB.DataType) 36 assert.Equal(t, npA.IndexFilterable, npB.IndexFilterable) 37 assert.Equal(t, npA.IndexSearchable, npB.IndexSearchable) 38 assert.Equal(t, npA.Tokenization, npB.Tokenization) 39 40 if _, isNested := schema.AsNested(npA.DataType); isNested { 41 AssertNestedPropsMatch(t, npA.NestedProperties, npB.NestedProperties) 42 } 43 } 44 }