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

Function TestProcessTaskIndex

worker/worker_test.go:450–501  ·  view source on GitHub ↗

Index-related test. Similar to TestProcessTaskIndeMLayer except we call MergeLists in between a lot of updates.

(t *testing.T)

Source from the content-addressed store, hash-verified

448// Index-related test. Similar to TestProcessTaskIndeMLayer except we call
449// MergeLists in between a lot of updates.
450func TestProcessTaskIndex(t *testing.T) {
451 dg := initClusterTest(t, `friend:string @index(term) .`)
452
453 resp, err := runQuery(dg, "friend", nil, []string{"anyofterms", "", "hey photon"})
454 require.NoError(t, err)
455 require.JSONEq(t, `{
456 "q": [
457 { "uid": "0xa" },
458 { "uid": "0xc" }
459 ]
460 }`,
461 string(resp.Json),
462 )
463
464 // Now try changing 12's friend value from "photon" to "notphotonExtra" to
465 // "notphoton".
466 setClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "notphotonExtra"))
467 setClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "notphoton"))
468
469 // Issue a similar query.
470 resp, err = runQuery(dg, "friend", nil,
471 []string{"anyofterms", "", "hey photon notphoton notphotonExtra"})
472 require.NoError(t, err)
473 require.JSONEq(t, `{
474 "q": [
475 { "uid": "0xa" },
476 { "uid": "0xc" }
477 ]
478 }`,
479 string(resp.Json),
480 )
481
482 // Try redundant deletes.
483 delClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 10, "photon"))
484 delClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 10, "photon"))
485
486 // Delete followed by set.
487 delClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "notphoton"))
488 setClusterEdge(t, dg, fmt.Sprintf("<%#x> <friend> %q .", 12, "ignored"))
489
490 // Issue a similar query.
491 resp, err = runQuery(dg, "friend", nil,
492 []string{"anyofterms", "", "photon notphoton ignored"})
493 require.NoError(t, err)
494 require.JSONEq(t, `{
495 "q": [
496 { "uid": "0xc" }
497 ]
498 }`,
499 string(resp.Json),
500 )
501}
502
503func TestMain(m *testing.M) {
504 posting.Config.CommitFraction = 0.10

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