(t *testing.T)
| 1470 | } |
| 1471 | |
| 1472 | func TestQueryParent(t *testing.T) { |
| 1473 | testQueryTypes(t, memIndexTypes, func(qt *queryTest) { |
| 1474 | id := qt.id |
| 1475 | |
| 1476 | pdir1 := id.NewPlannedPermanode("some_dir_1") |
| 1477 | pdir2 := id.NewPlannedPermanode("some_dir_2") |
| 1478 | p1 := id.NewPlannedPermanode("1") |
| 1479 | p2 := id.NewPlannedPermanode("2") |
| 1480 | p3 := id.NewPlannedPermanode("3") |
| 1481 | |
| 1482 | id.AddAttribute(pdir1, "camliMember", p1.String()) |
| 1483 | id.AddAttribute(pdir1, "camliPath:foo", p2.String()) |
| 1484 | id.AddAttribute(pdir1, "other", p3.String()) |
| 1485 | |
| 1486 | id.AddAttribute(pdir2, "camliPath:bar", p1.String()) |
| 1487 | |
| 1488 | // Make p1, p2, and p3 actually exist. (permanodes without attributes are dead) |
| 1489 | id.AddAttribute(p1, "x", "x") |
| 1490 | id.AddAttribute(p2, "x", "x") |
| 1491 | id.AddAttribute(p3, "x", "x") |
| 1492 | |
| 1493 | sq := &SearchQuery{ |
| 1494 | Constraint: &Constraint{ |
| 1495 | Permanode: &PermanodeConstraint{ |
| 1496 | Relation: &RelationConstraint{ |
| 1497 | Relation: "child", |
| 1498 | Any: &Constraint{ |
| 1499 | BlobRefPrefix: p1.String(), |
| 1500 | }, |
| 1501 | }, |
| 1502 | }, |
| 1503 | }, |
| 1504 | } |
| 1505 | qt.wantRes(sq, pdir1, pdir2) |
| 1506 | |
| 1507 | sq = &SearchQuery{ |
| 1508 | Constraint: &Constraint{ |
| 1509 | Permanode: &PermanodeConstraint{ |
| 1510 | Relation: &RelationConstraint{ |
| 1511 | Relation: "child", |
| 1512 | Any: &Constraint{ |
| 1513 | BlobRefPrefix: p2.String(), |
| 1514 | }, |
| 1515 | }, |
| 1516 | }, |
| 1517 | }, |
| 1518 | } |
| 1519 | qt.wantRes(sq, pdir1) |
| 1520 | |
| 1521 | sq = &SearchQuery{ |
| 1522 | Constraint: &Constraint{ |
| 1523 | Permanode: &PermanodeConstraint{ |
| 1524 | Relation: &RelationConstraint{ |
| 1525 | Relation: "child", |
| 1526 | Any: &Constraint{ |
| 1527 | BlobRefPrefix: p3.String(), |
| 1528 | }, |
| 1529 | }, |
nothing calls this directly
no test coverage detected