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

Function TestDropPredicate

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

Source from the content-addressed store, hash-verified

419}
420
421func TestDropPredicate(t *testing.T) {
422 // Add new predicate with several indices.
423 s1 := testSchema + "\n numerology: string @index(term) .\n"
424 setSchema(s1)
425 triples := `
426 <0x666> <numerology> "This number is evil" .
427 <0x777> <numerology> "This number is good" .
428 `
429 require.NoError(t, addTriplesToCluster(triples))
430
431 // Verify queries work as expected.
432 q1 := `
433 {
434 me(func: anyofterms(numerology, "number")) {
435 uid
436 numerology
437 }
438 }`
439 js := processQueryNoErr(t, q1)
440 require.JSONEq(t, `{"data": {"me": [
441 {"uid": "0x666", "numerology": "This number is evil"},
442 {"uid": "0x777", "numerology": "This number is good"}
443 ]}}`, js)
444
445 // Finally, drop the predicate and verify the query no longer works because
446 // the index was dropped when all the data for that predicate was deleted.
447 dropPredicate("numerology")
448 _, err := processQuery(context.Background(), t, q1)
449 require.Error(t, err)
450 require.Contains(t, err.Error(), "Attribute numerology is not indexed with type term")
451
452 // Finally, restore the schema.
453 setSchema(testSchema)
454}
455
456func TestNestedExpandAll(t *testing.T) {
457 query := `{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected