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

Function TestSchemaMutationCountAdd

dgraph/cmd/alpha/run_test.go:575–611  ·  view source on GitHub ↗

add count edges

(t *testing.T)

Source from the content-addressed store, hash-verified

573
574// add count edges
575func TestSchemaMutationCountAdd(t *testing.T) {
576 var q1 = `
577 {
578 user(func:eq(count(friend),4)) {
579 name
580 }
581 }
582 `
583 var m = `
584 {
585 set {
586 # comment line should be ignored
587 <0x1> <name> "Alice" .
588 <0x01> <friend> <0x02> .
589 <0x01> <friend> <0x03> .
590 <0x01> <friend> <0x04> .
591 <0x01> <friend> <0x05> .
592 }
593 }
594 `
595
596 var s = `
597 friend: [uid] @count .
598 `
599
600 // reset Schema
601 require.NoError(t, schema.ParseBytes([]byte(""), 1))
602 require.NoError(t, runMutation(m))
603
604 // add index to name
605 require.NoError(t, alterSchemaWithRetry(s))
606
607 time.Sleep(10 * time.Millisecond)
608 output, err := runGraphqlQuery(q1)
609 require.NoError(t, err)
610 require.JSONEq(t, `{"data": {"user":[{"name":"Alice"}]}}`, output)
611}
612
613func TestJsonMutation(t *testing.T) {
614 var q1 = `

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