github.com/weaviate/weaviate@v1.24.6/adapters/handlers/graphql/local/get/class_builder_references_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 get 13 14 import ( 15 "testing" 16 17 "github.com/stretchr/testify/assert" 18 "github.com/weaviate/weaviate/entities/additional" 19 "github.com/weaviate/weaviate/entities/dto" 20 ) 21 22 func TestGetNoNetworkRequestIsMadeWhenUserDoesntWantNetworkRef(t *testing.T) { 23 t.Parallel() 24 25 resolver := newMockResolver() 26 27 expectedParams := dto.GetParams{ 28 ClassName: "SomeThing", 29 AdditionalProperties: additional.Properties{ 30 ID: true, 31 }, 32 } 33 34 resolverResponse := []interface{}{ 35 map[string]interface{}{ 36 "_additional": map[string]interface{}{ 37 "id": "some-uuid-for-the-local-class", 38 }, 39 }, 40 } 41 42 resolver.On("GetClass", expectedParams). 43 Return(resolverResponse, nil).Once() 44 45 query := "{ Get { SomeThing { _additional { id } } } }" 46 result := resolver.AssertResolve(t, query).Result 47 48 expectedResult := map[string]interface{}{ 49 "Get": map[string]interface{}{ 50 "SomeThing": []interface{}{ 51 map[string]interface{}{ 52 "_additional": map[string]interface{}{ 53 "id": "some-uuid-for-the-local-class", 54 }, 55 }, 56 }, 57 }, 58 } 59 60 assert.Equal(t, expectedResult, result, "should resolve the network cross-ref correctly") 61 }