(t *testing.T)
| 573 | } |
| 574 | |
| 575 | func TestSingleString(t *testing.T) { |
| 576 | dir, err := os.MkdirTemp("", "storetest_") |
| 577 | x.Check(err) |
| 578 | defer os.RemoveAll(dir) |
| 579 | |
| 580 | opt := badger.DefaultOptions(dir) |
| 581 | ps, err := badger.OpenManaged(opt) |
| 582 | x.Check(err) |
| 583 | pstore = ps |
| 584 | posting.Init(ps, 0, false) |
| 585 | Init(ps) |
| 586 | err = schema.ParseBytes([]byte("singleUidTest: string @index(exact) @unique ."), 1) |
| 587 | require.NoError(t, err) |
| 588 | |
| 589 | ctx := context.Background() |
| 590 | txn := posting.Oracle().RegisterStartTs(5) |
| 591 | attr := x.AttrInRootNamespace("singleUidTest") |
| 592 | |
| 593 | // Txn 1. Set 1 -> david 2 -> blush |
| 594 | x.Check(runMutation(ctx, &pb.DirectedEdge{ |
| 595 | Value: []byte("david"), |
| 596 | Attr: attr, |
| 597 | Entity: 1, |
| 598 | Op: pb.DirectedEdge_SET, |
| 599 | }, txn)) |
| 600 | |
| 601 | x.Check(runMutation(ctx, &pb.DirectedEdge{ |
| 602 | Value: []byte("blush"), |
| 603 | Attr: attr, |
| 604 | Entity: 2, |
| 605 | Op: pb.DirectedEdge_SET, |
| 606 | }, txn)) |
| 607 | |
| 608 | txn.Update() |
| 609 | writer := posting.NewTxnWriter(pstore) |
| 610 | require.NoError(t, txn.CommitToDisk(writer, 7)) |
| 611 | require.NoError(t, writer.Flush()) |
| 612 | txn.UpdateCachedKeys(7) |
| 613 | |
| 614 | // Txn 2. Set 2 -> david 1 -> blush |
| 615 | txn = posting.Oracle().RegisterStartTs(9) |
| 616 | |
| 617 | x.Check(runMutation(ctx, &pb.DirectedEdge{ |
| 618 | Value: []byte("david"), |
| 619 | Attr: attr, |
| 620 | Entity: 2, |
| 621 | Op: pb.DirectedEdge_SET, |
| 622 | }, txn)) |
| 623 | |
| 624 | x.Check(runMutation(ctx, &pb.DirectedEdge{ |
| 625 | Value: []byte("blush"), |
| 626 | Attr: attr, |
| 627 | Entity: 1, |
| 628 | Op: pb.DirectedEdge_SET, |
| 629 | }, txn)) |
| 630 | |
| 631 | txn.Update() |
| 632 | writer = posting.NewTxnWriter(pstore) |
nothing calls this directly
no test coverage detected