Index-related test. Similar to TestProcessTaskIndeMLayer except we call MergeLists in between a lot of updates.
(t *testing.T)
| 448 | // Index-related test. Similar to TestProcessTaskIndeMLayer except we call |
| 449 | // MergeLists in between a lot of updates. |
| 450 | func 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 | |
| 503 | func TestMain(m *testing.M) { |
| 504 | posting.Config.CommitFraction = 0.10 |
nothing calls this directly
no test coverage detected