MCPcopy
hub / github.com/dgraph-io/dgraph / TestReverseEdge

Function TestReverseEdge

worker/mutation_unit_test.go:24–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestReverseEdge(t *testing.T) {
25 dir, err := os.MkdirTemp("", "storetest_")
26 x.Check(err)
27 defer os.RemoveAll(dir)
28
29 opt := badger.DefaultOptions(dir)
30 ps, err := badger.OpenManaged(opt)
31 x.Check(err)
32 pstore = ps
33 // Not using posting list cache
34 posting.Init(ps, 0, false)
35 Init(ps)
36 err = schema.ParseBytes([]byte("revc: [uid] @reverse @count ."), 1)
37 require.NoError(t, err)
38
39 ctx := context.Background()
40 txn := posting.Oracle().RegisterStartTs(5)
41 attr := x.AttrInRootNamespace("revc")
42
43 edge := &pb.DirectedEdge{
44 ValueId: 2,
45 Attr: attr,
46 Entity: 1,
47 Op: pb.DirectedEdge_DEL,
48 }
49
50 x.Check(runMutation(ctx, edge, txn))
51 x.Check(runMutation(ctx, edge, txn))
52
53 pl, err := txn.Get(x.DataKey(attr, 1))
54 require.NoError(t, err)
55 pl.RLock()
56 c := pl.GetLength(5)
57 pl.RUnlock()
58 require.Equal(t, 0, c)
59}
60
61func TestReverseEdgeSetDel(t *testing.T) {
62 dir, err := os.MkdirTemp("", "storetest_")

Callers

nothing calls this directly

Calls 14

CheckFunction · 0.92
InitFunction · 0.92
ParseBytesFunction · 0.92
OracleFunction · 0.92
AttrInRootNamespaceFunction · 0.92
DataKeyFunction · 0.92
RemoveAllMethod · 0.80
RegisterStartTsMethod · 0.80
RLockMethod · 0.80
GetLengthMethod · 0.80
RUnlockMethod · 0.80
InitFunction · 0.70

Tested by

no test coverage detected