MCPcopy
hub / github.com/dgraph-io/dgraph / TestDeleteAndReadReverse

Function TestDeleteAndReadReverse

query/query4_test.go:238–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

236}
237
238func TestDeleteAndReadReverse(t *testing.T) {
239 // Add new predicate with a reverse edge.
240 s1 := testSchema + "\n child_pred: uid @reverse .\n"
241 setSchema(s1)
242 triples := `<0x666> <child_pred> <0x777> .`
243 require.NoError(t, addTriplesToCluster(triples))
244
245 // Verify reverse edges works as expected.
246 q1 := `
247 {
248 me(func: uid(0x777)) {
249 ~child_pred {
250 uid
251 }
252 }
253 }`
254 js := processQueryNoErr(t, q1)
255 require.JSONEq(t, `{"data": {"me": [{"~child_pred": [{"uid": "0x666"}]}]}}`, js)
256
257 // Remove the reverse edges and verify the previous query is no longer supported.
258 s2 := testSchema + "\n child_pred: uid .\n"
259 setSchema(s2)
260 _, err := processQuery(context.Background(), t, q1)
261 require.Error(t, err)
262 require.Contains(t, err.Error(), "Predicate child_pred doesn't have reverse edge")
263
264 // Re-add reverse edges and verify that the original query works again.
265 setSchema(s1)
266 js = processQueryNoErr(t, q1)
267 require.JSONEq(t, `{"data": {"me": [{"~child_pred": [{"uid": "0x666"}]}]}}`, js)
268
269 // Finally, drop the predicate and restore schema.
270 dropPredicate("child_pred")
271 setSchema(testSchema)
272}
273
274func TestSchemaUpdateNoConflict(t *testing.T) {
275 // Verify schema is as expected for the predicate with noconflict directive.

Callers

nothing calls this directly

Calls 6

setSchemaFunction · 0.70
addTriplesToClusterFunction · 0.70
processQueryNoErrFunction · 0.70
processQueryFunction · 0.70
dropPredicateFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected