File size: 4,191 Bytes
b110593
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//                           _       _
// __      _____  __ ___   ___  __ _| |_ ___
// \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
//  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
//   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
//
//  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
//
//  CONTACT: [email protected]
//

package test

// func TestCanAddSingleNetworkRef(t *testing.T) {
// 	networkRefID := "711da979-4b0b-41e2-bcb8-fcc03554c7c8"
// 	thingID := assertCreateThing(t, "TestThing", map[string]interface{}{
// 		"testReference": []interface{}{
// 			map[string]interface{}{
// 				"beacon": "weaviate://RemoteWeaviateForAcceptanceTest/things/" + networkRefID,
// 			},
// 		},
// 	})

// 	t.Run("it can query the resource again to verify the cross ref was added", func(t *testing.T) {
// 		thing := assertGetThingEventually(t, thingID)
// 		list := thing.Schema.(map[string]interface{})["testReference"]
// 		require.NotNil(t, list, "cross-ref is present")
// 		cref := list.([]interface{})[0].(map[string]interface{})
// 		assert.Equal(t, cref["beacon"], "weaviate://RemoteWeaviateForAcceptanceTest/things/"+networkRefID)
// 	})

// 	t.Run("an implicit schema update has happened, we now include the network ref's class", func(t *testing.T) {
// 		schema := assertGetSchema(t)
// 		require.NotNil(t, schema.Things)
// 		class := assertClassInSchema(t, schema.Things, "TestThing")
// 		prop := assertPropertyInClass(t, class, "testReference")
// 		expectedDataType := []string{"TestThingTwo", "RemoteWeaviateForAcceptanceTest/Instruments"}
// 		assert.Equal(t, expectedDataType, prop.DataType, "prop should have old and newly added dataTypes")
// 	})

// 	t.Run("it can query the reference through the graphql api", func(t *testing.T) {
// 		result := graphql.AssertGraphQL(t, helper.RootAuth,
// 			"{  Get { Things { TestThing { TestReference { ... on RemoteWeaviateForAcceptanceTest__Instruments { name } } } } } }")
// 		things := result.Get("Get", "Things", "TestThing").AsSlice()
// 		assert.Contains(t, things, parseJSONObj(`{"TestReference":[{"name": "Talkbox"}]}`))
// 	})
// }

// func TestCanPatchNetworkRef(t *testing.T) {
// 	t.Parallel()

// 	thingID := assertCreateThing(t, "TestThing", nil)
// 	assertGetThingEventually(t, thingID)
// 	networkRefID := "711da979-4b0b-41e2-bcb8-fcc03554c7c8"

// 	op := "add"
// 	path := "/schema/testReference"

// 	patch := &models.PatchDocument{
// 		Op:   &op,
// 		Path: &path,
// 		Value: []interface{}{
// 			map[string]interface{}{
// 				"beacon": "weaviate://RemoteWeaviateForAcceptanceTest/things/" + networkRefID,
// 			},
// 		},
// 	}

// 	t.Run("it can apply the patch", func(t *testing.T) {
// 		params := things.NewThingsPatchParams().
// 			WithBody([]*models.PatchDocument{patch}).
// 			WithID(thingID)
// 		patchResp, err := helper.Client(t).Things.ThingsPatch(params, nil)
// 		helper.AssertRequestOk(t, patchResp, err, nil)
// 	})

// 	t.Run("it can query the resource again to verify the cross ref was added", func(t *testing.T) {
// 		patchedThing := assertGetThing(t, thingID)
// 		list := patchedThing.Schema.(map[string]interface{})["testReference"]
// 		require.NotNil(t, list, "cross-ref is present")
// 		cref := list.([]interface{})[0].(map[string]interface{})
// 		assert.Equal(t, cref["beacon"], "weaviate://RemoteWeaviateForAcceptanceTest/things/"+networkRefID)
// 	})

// 	t.Run("an implicit schema update has happened, we now include the network ref's class", func(t *testing.T) {
// 		schema := assertGetSchema(t)
// 		require.NotNil(t, schema.Things)
// 		class := assertClassInSchema(t, schema.Things, "TestThing")
// 		prop := assertPropertyInClass(t, class, "testReference")
// 		expectedDataType := []string{"TestThingTwo", "RemoteWeaviateForAcceptanceTest/Instruments"}
// 		assert.Equal(t, expectedDataType, prop.DataType, "prop should have old and newly added dataTypes")
// 	})
// }

// func parseJSONObj(text string) interface{} {
// 	var result interface{}
// 	err := json.Unmarshal([]byte(text), &result)

// 	if err != nil {
// 		panic(err)
// 	}

// 	return result
// }