github.com/weaviate/weaviate@v1.24.6/usecases/modulecomponents/arguments/nearThermal/graphql_argument_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 nearThermal 13 14 import ( 15 "testing" 16 17 "github.com/stretchr/testify/assert" 18 "github.com/tailor-inc/graphql" 19 ) 20 21 func TestNearThermalGraphQLArgument(t *testing.T) { 22 t.Run("should generate nearThermal argument properly", func(t *testing.T) { 23 // given 24 prefix := "Prefix" 25 classname := "Class" 26 // when 27 nearThermal := nearThermalArgument(prefix, classname) 28 29 // then 30 // the built graphQL field needs to support this structure: 31 // nearThermal: { 32 // thermal: "base64;encoded,thermal_image", 33 // distance: 0.9 34 // targetVectors: ["targetVector"] 35 // } 36 assert.NotNil(t, nearThermal) 37 assert.Equal(t, "Multi2VecBindPrefixClassNearThermalInpObj", nearThermal.Type.Name()) 38 answerFields, ok := nearThermal.Type.(*graphql.InputObject) 39 assert.True(t, ok) 40 assert.NotNil(t, answerFields) 41 assert.Equal(t, 4, len(answerFields.Fields())) 42 fields := answerFields.Fields() 43 thermal := fields["thermal"] 44 thermalNonNull, thermalNonNullOK := thermal.Type.(*graphql.NonNull) 45 assert.True(t, thermalNonNullOK) 46 assert.Equal(t, "String", thermalNonNull.OfType.Name()) 47 assert.NotNil(t, thermal) 48 assert.NotNil(t, fields["certainty"]) 49 assert.NotNil(t, fields["distance"]) 50 targetVectors := fields["targetVectors"] 51 targetVectorsList, targetVectorsListOK := targetVectors.Type.(*graphql.List) 52 assert.True(t, targetVectorsListOK) 53 assert.Equal(t, "String", targetVectorsList.OfType.Name()) 54 assert.NotNil(t, targetVectors) 55 }) 56 }