(t *testing.T)
| 810 | } |
| 811 | |
| 812 | func TestAfterUIDCount(t *testing.T) { |
| 813 | key := x.DataKey(x.AttrInRootNamespace("value"), 22) |
| 814 | ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) |
| 815 | require.NoError(t, err) |
| 816 | // Set value to cars and merge to BadgerDB. |
| 817 | edge := &pb.DirectedEdge{} |
| 818 | |
| 819 | txn := &Txn{StartTs: 1} |
| 820 | for i := 100; i < 300; i++ { |
| 821 | edge.ValueId = uint64(i) |
| 822 | addMutationHelper(t, ol, edge, Set, txn) |
| 823 | } |
| 824 | require.EqualValues(t, 200, ol.Length(txn.StartTs, 0)) |
| 825 | require.EqualValues(t, 100, ol.Length(txn.StartTs, 199)) |
| 826 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 300)) |
| 827 | |
| 828 | // Delete half of the edges. |
| 829 | for i := 100; i < 300; i += 2 { |
| 830 | edge.ValueId = uint64(i) |
| 831 | addMutationHelper(t, ol, edge, Del, txn) |
| 832 | } |
| 833 | require.EqualValues(t, 100, ol.Length(txn.StartTs, 0)) |
| 834 | require.EqualValues(t, 50, ol.Length(txn.StartTs, 199)) |
| 835 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 300)) |
| 836 | |
| 837 | // Try to delete half of the edges. Redundant deletes. |
| 838 | for i := 100; i < 300; i += 2 { |
| 839 | edge.ValueId = uint64(i) |
| 840 | addMutationHelper(t, ol, edge, Del, txn) |
| 841 | } |
| 842 | require.EqualValues(t, 100, ol.Length(txn.StartTs, 0)) |
| 843 | require.EqualValues(t, 50, ol.Length(txn.StartTs, 199)) |
| 844 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 300)) |
| 845 | |
| 846 | // Delete everything. |
| 847 | for i := 100; i < 300; i++ { |
| 848 | edge.ValueId = uint64(i) |
| 849 | addMutationHelper(t, ol, edge, Del, txn) |
| 850 | } |
| 851 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 0)) |
| 852 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 199)) |
| 853 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 300)) |
| 854 | |
| 855 | // Insert 1/4 of the edges. |
| 856 | for i := 100; i < 300; i += 4 { |
| 857 | edge.ValueId = uint64(i) |
| 858 | addMutationHelper(t, ol, edge, Set, txn) |
| 859 | } |
| 860 | require.EqualValues(t, 50, ol.Length(txn.StartTs, 0)) |
| 861 | require.EqualValues(t, 25, ol.Length(txn.StartTs, 199)) |
| 862 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 300)) |
| 863 | |
| 864 | // Insert 1/4 of the edges. |
| 865 | for i := 100; i < 300; i += 4 { |
| 866 | edge.ValueId = uint64(i) |
| 867 | addMutationHelper(t, ol, edge, Set, txn) |
| 868 | } |
| 869 | require.EqualValues(t, 50, ol.Length(txn.StartTs, 0)) // Expect no change. |
nothing calls this directly
no test coverage detected