MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / TestSchemaMutationIndexAdd

Function TestSchemaMutationIndexAdd

dgraph/cmd/alpha/run_test.go:415–447  ·  view source on GitHub ↗

add index

(t *testing.T)

Source from the content-addressed store, hash-verified

413
414// add index
415func TestSchemaMutationIndexAdd(t *testing.T) {
416 var q1 = `
417 {
418 user(func:anyofterms(name, "Alice")) {
419 name
420 }
421 }
422 `
423 var m = `
424 {
425 set {
426 # comment line should be ignored
427 <0x1> <name> "Alice" .
428 }
429 }
430 `
431
432 var s = `
433 name:string @index(term) .
434 `
435
436 // reset Schema
437 require.NoError(t, schema.ParseBytes([]byte(""), 1))
438 require.NoError(t, runMutation(m))
439
440 // add index to name
441 require.NoError(t, alterSchemaWithRetry(s))
442
443 output, err := runGraphqlQuery(q1)
444 require.NoError(t, err)
445 require.JSONEq(t, `{"data": {"user":[{"name":"Alice"}]}}`, output)
446
447}
448
449// Remove index
450func TestSchemaMutationIndexRemove(t *testing.T) {

Callers

nothing calls this directly

Calls 4

ParseBytesFunction · 0.92
alterSchemaWithRetryFunction · 0.85
runGraphqlQueryFunction · 0.85
runMutationFunction · 0.70

Tested by

no test coverage detected