(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestDeleteSetWithVarEdgeCorruptsData(t *testing.T) { |
| 94 | // Setup temporary directory for Badger DB |
| 95 | dir, err := os.MkdirTemp("", "storetest_") |
| 96 | require.NoError(t, err) |
| 97 | defer os.RemoveAll(dir) |
| 98 | |
| 99 | opt := badger.DefaultOptions(dir) |
| 100 | ps, err := badger.OpenManaged(opt) |
| 101 | require.NoError(t, err) |
| 102 | posting.Init(ps, 0, false) |
| 103 | Init(ps) |
| 104 | |
| 105 | // Set schema |
| 106 | schemaTxt := ` |
| 107 | room: string @index(hash) @upsert . |
| 108 | person: string @index(hash) @upsert . |
| 109 | office: uid @reverse @count . |
| 110 | ` |
| 111 | err = schema.ParseBytes([]byte(schemaTxt), 1) |
| 112 | require.NoError(t, err) |
| 113 | |
| 114 | ctx := context.Background() |
| 115 | attrRoom := x.AttrInRootNamespace("room") |
| 116 | attrPerson := x.AttrInRootNamespace("person") |
| 117 | attrOffice := x.AttrInRootNamespace("office") |
| 118 | |
| 119 | uidRoom := uint64(1) |
| 120 | uidJohn := uint64(2) |
| 121 | |
| 122 | runMutation := func(startTs, commitTs uint64, edges []*pb.DirectedEdge) { |
| 123 | txn := posting.Oracle().RegisterStartTs(startTs) |
| 124 | for _, edge := range edges { |
| 125 | require.NoError(t, runMutation(ctx, edge, txn)) |
| 126 | } |
| 127 | txn.Update() |
| 128 | writer := posting.NewTxnWriter(ps) |
| 129 | require.NoError(t, txn.CommitToDisk(writer, commitTs)) |
| 130 | require.NoError(t, writer.Flush()) |
| 131 | txn.UpdateCachedKeys(commitTs) |
| 132 | } |
| 133 | |
| 134 | // Initial mutation: Set John → Leopard |
| 135 | runMutation(1, 3, []*pb.DirectedEdge{ |
| 136 | { |
| 137 | Entity: uidJohn, |
| 138 | Attr: attrPerson, |
| 139 | Value: []byte("John Smith"), |
| 140 | ValueType: pb.Posting_STRING, |
| 141 | Op: pb.DirectedEdge_SET, |
| 142 | }, |
| 143 | { |
| 144 | Entity: uidRoom, |
| 145 | Attr: attrRoom, |
| 146 | Value: []byte("Leopard"), |
| 147 | ValueType: pb.Posting_STRING, |
| 148 | Op: pb.DirectedEdge_SET, |
| 149 | }, |
| 150 | { |
nothing calls this directly
no test coverage detected