github.com/weaviate/weaviate@v1.24.6/test/acceptance/actions/network_refs_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 test 13 14 // func TestCanAddSingleNetworkRef(t *testing.T) { 15 // networkRefID := "711da979-4b0b-41e2-bcb8-fcc03554c7c8" 16 // actionID := assertCreateAction(t, "TestAction", map[string]interface{}{ 17 // "testReference": []interface{}{ 18 // map[string]interface{}{ 19 // "beacon": strfmt.UUID(fmt.Sprintf("weaviate://RemoteWeaviateForAcceptanceTest/things/%s", networkRefID)), 20 // }, 21 // }, 22 // }) 23 // assertGetActionEventually(t, actionID) 24 25 // t.Run("it can query the resource again to verify the cross ref was added", func(t *testing.T) { 26 // action := assertGetAction(t, actionID) 27 // list := action.Schema.(map[string]interface{})["testReference"] 28 // require.NotNil(t, list, "cross-ref is present") 29 // rawCref := list.([]interface{})[0] 30 // cref := rawCref.(map[string]interface{}) 31 // assert.Equal(t, 32 // fmt.Sprintf("weaviate://RemoteWeaviateForAcceptanceTest/things/%s", networkRefID), cref["beacon"]) 33 // }) 34 35 // t.Run("an implicit schema update has happened, we now include the network ref's class", func(t *testing.T) { 36 // schema := assertGetSchema(t) 37 // require.NotNil(t, schema.Actions) 38 // class := assertClassInSchema(t, schema.Actions, "TestAction") 39 // prop := assertPropertyInClass(t, class, "testReference") 40 // expectedDataType := []string{"TestThing", "RemoteWeaviateForAcceptanceTest/Instruments"} 41 // assert.Equal(t, expectedDataType, prop.DataType, "prop should have old and newly added dataTypes") 42 // }) 43 // } 44 45 // func TestCanPatchSingleNetworkRef(t *testing.T) { 46 // t.Parallel() 47 48 // actionID := assertCreateAction(t, "TestAction", nil) 49 // assertGetActionEventually(t, actionID) 50 // networkRefID := "711da979-4b0b-41e2-bcb8-fcc03554c7c8" 51 52 // op := "add" 53 // path := "/schema/testReference" 54 55 // patch := &models.PatchDocument{ 56 // Op: &op, 57 // Path: &path, 58 // Value: []interface{}{ 59 // map[string]interface{}{ 60 // "beacon": strfmt.UUID(fmt.Sprintf("weaviate://RemoteWeaviateForAcceptanceTest/things/%s", networkRefID)), 61 // }, 62 // }, 63 // } 64 65 // t.Run("it can apply the patch", func(t *testing.T) { 66 // params := actions.NewActionsPatchParams(). 67 // WithBody([]*models.PatchDocument{patch}). 68 // WithID(actionID) 69 // patchResp, err := helper.Client(t).Actions.ActionsPatch(params, nil) 70 // helper.AssertRequestOk(t, patchResp, err, nil) 71 // }) 72 73 // t.Run("it can query the resource again to verify the cross ref was added", func(t *testing.T) { 74 // patchedAction := assertGetAction(t, actionID) 75 // list := patchedAction.Schema.(map[string]interface{})["testReference"] 76 // require.NotNil(t, list, "cross-ref is present") 77 // rawCref := list.([]interface{})[0] 78 // cref := rawCref.(map[string]interface{}) 79 // assert.Equal(t, fmt.Sprintf("weaviate://RemoteWeaviateForAcceptanceTest/things/%s", networkRefID), cref["beacon"]) 80 // }) 81 82 // t.Run("an implicit schema update has happened, we now include the network ref's class", func(t *testing.T) { 83 // schema := assertGetSchema(t) 84 // require.NotNil(t, schema.Actions) 85 // class := assertClassInSchema(t, schema.Actions, "TestAction") 86 // prop := assertPropertyInClass(t, class, "testReference") 87 // expectedDataType := []string{"TestThing", "RemoteWeaviateForAcceptanceTest/Instruments"} 88 // assert.Equal(t, expectedDataType, prop.DataType, "prop should have old and newly added dataTypes") 89 // }) 90 // }