@@ -58,6 +58,68 @@ func TestReverseEdge(t *testing.T) {
5858 require .Equal (t , c , 0 )
5959}
6060
61+ func TestReverseEdgeSetDel (t * testing.T ) {
62+ dir , err := os .MkdirTemp ("" , "storetest_" )
63+ x .Check (err )
64+ defer os .RemoveAll (dir )
65+
66+ opt := badger .DefaultOptions (dir )
67+ ps , err := badger .OpenManaged (opt )
68+ x .Check (err )
69+ pstore = ps
70+ // Not using posting list cache
71+ posting .Init (ps , 0 , false )
72+ Init (ps )
73+ err = schema .ParseBytes ([]byte ("revc: [uid] @reverse @count ." ), 1 )
74+ require .NoError (t , err )
75+
76+ ctx := context .Background ()
77+ txn := posting .Oracle ().RegisterStartTs (5 )
78+ attr := x .AttrInRootNamespace ("revc" )
79+
80+ edgeDel := & pb.DirectedEdge {
81+ ValueId : 2 ,
82+ Attr : attr ,
83+ Entity : 3 ,
84+ Op : pb .DirectedEdge_DEL ,
85+ }
86+
87+ edgeSet1 := & pb.DirectedEdge {
88+ ValueId : 2 ,
89+ Attr : attr ,
90+ Entity : 1 ,
91+ Op : pb .DirectedEdge_SET ,
92+ }
93+
94+ edgeSet2 := & pb.DirectedEdge {
95+ ValueId : 2 ,
96+ Attr : attr ,
97+ Entity : 3 ,
98+ Op : pb .DirectedEdge_SET ,
99+ }
100+
101+
102+ edgeSet3 := & pb.DirectedEdge {
103+ ValueId : 2 ,
104+ Attr : attr ,
105+ Entity : 4 ,
106+ Op : pb .DirectedEdge_SET ,
107+ }
108+
109+
110+ x .Check (runMutation (ctx , edgeSet1 , txn ))
111+ x .Check (runMutation (ctx , edgeSet2 , txn ))
112+ x .Check (runMutation (ctx , edgeSet3 , txn ))
113+ x .Check (runMutation (ctx , edgeDel , txn ))
114+
115+ pl , err := txn .Get (x .ReverseKey (attr , 2 ))
116+ require .NoError (t , err )
117+ pl .RLock ()
118+ c := pl .GetLength (5 )
119+ pl .RUnlock ()
120+ require .Equal (t , 2 , c )
121+ }
122+
61123func TestConvertEdgeType (t * testing.T ) {
62124 var testEdges = []struct {
63125 input * pb.DirectedEdge
0 commit comments