github.com/weaviate/weaviate@v1.24.6/usecases/schema/remove_duplicate_props_test.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 schema 13 14 import ( 15 "context" 16 "testing" 17 18 "github.com/stretchr/testify/assert" 19 "github.com/stretchr/testify/require" 20 "github.com/weaviate/weaviate/entities/models" 21 "github.com/weaviate/weaviate/entities/schema" 22 ) 23 24 func TestStartupWithDuplicateProps(t *testing.T) { 25 sch := State{ 26 ObjectSchema: &models.Schema{ 27 Classes: []*models.Class{ 28 { 29 Class: "MyClass", 30 VectorIndexType: "hnsw", 31 Properties: []*models.Property{ 32 { 33 Name: "prop_1", 34 DataType: schema.DataTypeInt.PropString(), 35 }, 36 { 37 Name: "prop_2", 38 DataType: []string{"Ref"}, 39 }, 40 { 41 Name: "prop_2", 42 DataType: []string{"Ref"}, 43 }, 44 { 45 Name: "prop_3", 46 DataType: []string{"Ref"}, 47 }, 48 { 49 Name: "prop_2", 50 DataType: []string{"Ref"}, 51 }, 52 { 53 Name: "prOP_2", 54 DataType: []string{"Ref"}, 55 }, 56 { 57 Name: "prop_4", 58 DataType: schema.DataTypeBoolean.PropString(), 59 }, 60 }, 61 }, 62 }, 63 }, 64 } 65 m, err := newManagerWithClusterAndTx(t, &fakeClusterState{ 66 hosts: []string{"node1"}, 67 }, 68 &fakeTxClient{}, &sch) 69 require.Nil(t, err) 70 71 actual, err := m.GetClass(context.Background(), nil, "MyClass") 72 require.Nil(t, err) 73 74 vTrue := true 75 vFalse := false 76 expected := &models.Class{ 77 Class: "MyClass", 78 VectorIndexType: "hnsw", 79 Properties: []*models.Property{ 80 { 81 Name: "prop_1", 82 DataType: schema.DataTypeInt.PropString(), 83 IndexFilterable: &vTrue, 84 IndexSearchable: &vFalse, 85 }, 86 { 87 Name: "prop_2", 88 DataType: []string{"Ref"}, 89 IndexFilterable: &vTrue, 90 IndexSearchable: &vFalse, 91 }, 92 { 93 Name: "prop_3", 94 DataType: []string{"Ref"}, 95 IndexFilterable: &vTrue, 96 IndexSearchable: &vFalse, 97 }, 98 { 99 Name: "prop_4", 100 DataType: schema.DataTypeBoolean.PropString(), 101 IndexFilterable: &vTrue, 102 IndexSearchable: &vFalse, 103 }, 104 }, 105 } 106 107 assert.Equal(t, expected.Properties, actual.Properties) 108 }