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

Function TestNormalizeJSONLimit

query/outputnode_test.go:55–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestNormalizeJSONLimit(t *testing.T) {
56 // Set default normalize limit.
57 x.Config.Limit = z.NewSuperFlag("normalize-node=10000;").MergeAndCheckDefault(worker.LimitDefaults)
58
59 if testing.Short() {
60 t.Skip("Skipping TestNormalizeJSONLimit")
61 }
62
63 enc := newEncoder()
64 n := enc.newNode(enc.idForAttr("root"))
65 require.NotNil(t, n)
66 for i := range 1000 {
67 require.NoError(t, enc.AddValue(n, enc.idForAttr(fmt.Sprintf("very long attr name %06d", i)),
68 types.ValueForType(types.StringID)))
69 child1 := enc.newNode(enc.idForAttr("child1"))
70 enc.AddListChild(n, child1)
71 for j := range 100 {
72 require.NoError(t, enc.AddValue(child1, enc.idForAttr(fmt.Sprintf("long child1 attr %06d", j)),
73 types.ValueForType(types.StringID)))
74 }
75 child2 := enc.newNode(enc.idForAttr("child2"))
76 enc.AddListChild(n, child2)
77 for j := range 100 {
78 require.NoError(t, enc.AddValue(child2, enc.idForAttr(fmt.Sprintf("long child2 attr %06d", j)),
79 types.ValueForType(types.StringID)))
80 }
81 child3 := enc.newNode(enc.idForAttr("child3"))
82 enc.AddListChild(n, child3)
83 for j := range 100 {
84 require.NoError(t, enc.AddValue(child3, enc.idForAttr(fmt.Sprintf("long child3 attr %06d", j)),
85 types.ValueForType(types.StringID)))
86 }
87 }
88 _, err := enc.normalize(n)
89 require.Error(t, err, "Couldn't evaluate @normalize directive - too many results")
90}
91
92func BenchmarkJsonMarshal(b *testing.B) {
93 inputStrings := [][]string{

Callers

nothing calls this directly

Calls 9

ValueForTypeFunction · 0.92
newEncoderFunction · 0.85
newNodeMethod · 0.80
idForAttrMethod · 0.80
AddValueMethod · 0.80
AddListChildMethod · 0.80
normalizeMethod · 0.80
SkipMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected