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

Function TestProcessTaskIndexMLayer

worker/worker_test.go:280–342  ·  view source on GitHub ↗

Index-related test. Similar to TestProcessTaskIndex but we call MergeLists only at the end. In other words, everything is happening only in mutation layers, and not committed to BadgerDB until near the end.

(t *testing.T)

Source from the content-addressed store, hash-verified

278// at the end. In other words, everything is happening only in mutation layers,
279// and not committed to BadgerDB until near the end.
280func TestProcessTaskIndexMLayer(t *testing.T) {
281 dg := initClusterTest(t, `friend:string @index(term) .`)
282
283 resp, err := runQuery(dg, "friend", nil, []string{"anyofterms", "", "hey photon"})
284 require.NoError(t, err)
285 require.JSONEq(t, `{
286 "q": [
287 { "uid": "0xa" },
288 { "uid": "0xc" }
289 ]
290 }`,
291 string(resp.Json),
292 )
293
294 // Now try changing 12's friend value from "photon" to "notphotonExtra" to
295 // "notphoton".
296 setClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "notphotonExtra"))
297 setClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "notphoton"))
298
299 // Issue a similar query.
300 resp, err = runQuery(dg, "friend", nil,
301 []string{"anyofterms", "", "hey photon notphoton notphotonExtra"})
302 require.NoError(t, err)
303 require.JSONEq(t, `{
304 "q": [
305 { "uid": "0xa" },
306 { "uid": "0xc" }
307 ]
308 }`,
309 string(resp.Json),
310 )
311
312 // Try redundant deletes.
313 delClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 10, "photon"))
314 delClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 10, "photon"))
315
316 // Delete followed by set.
317 delClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "notphoton"))
318 setClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "ignored"))
319
320 // Issue a similar query.
321 resp, err = runQuery(dg, "friend", nil,
322 []string{"anyofterms", "", "photon notphoton ignored"})
323 require.NoError(t, err)
324 require.JSONEq(t, `{
325 "q": [
326 { "uid": "0xc" }
327 ]
328 }`,
329 string(resp.Json),
330 )
331
332 resp, err = runQuery(dg, "friend", nil,
333 []string{"anyofterms", "", "photon notphoton ignored"})
334 require.NoError(t, err)
335 require.JSONEq(t, `{
336 "q": [
337 { "uid": "0xc" }

Callers

nothing calls this directly

Calls 4

initClusterTestFunction · 0.85
runQueryFunction · 0.70
setClusterEdgeFunction · 0.70
delClusterEdgeFunction · 0.70

Tested by

no test coverage detected