Skip to content

Commit

Permalink
added another smaller check
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 committed Sep 6, 2023
1 parent 73f0a2f commit 17c12f1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions internal/graph/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestMemory_index(t *testing.T) {
testMemory.index(ctx, B, []ocispec.Descriptor{C, D})

// check the memory: B exists in testMemory.predecessors, successors and indexed,
// C ONLY exists in predecessors
// C, D ONLY exists in predecessors
_, exists = testMemory.predecessors.Load(BKey)
if !exists {
t.Errorf("could not find the entry of %v in predecessors", B)
Expand All @@ -128,7 +128,18 @@ func TestMemory_index(t *testing.T) {
if exists {
t.Errorf("%v should not exist in indexed", C)
}

_, exists = testMemory.predecessors.Load(DKey)
if !exists {
t.Errorf("could not find the entry of %v in predecessors", D)
}
_, exists = testMemory.successors.Load(DKey)
if exists {
t.Errorf("%v should not exist in successors", D)
}
_, exists = testMemory.indexed.Load(DKey)
if exists {
t.Errorf("%v should not exist in indexed", D)
}
// predecessors[C] contains B, predecessors[D] contains B,
// successors[B] contains C and D
value, _ = testMemory.predecessors.Load(CKey)
Expand Down Expand Up @@ -157,7 +168,7 @@ func TestMemory_index(t *testing.T) {
// test 3: index "A -> D"
testMemory.index(ctx, A, []ocispec.Descriptor{D})

// predecessors[D] contains A and B, successors[A] contains D
// predecessors[D] contains A and B, successors[A] contains B and D
value, _ = testMemory.predecessors.Load(DKey)
DPreds = value.(*sync.Map)
_, exists = DPreds.Load(AKey)
Expand All @@ -170,6 +181,10 @@ func TestMemory_index(t *testing.T) {
}
value, _ = testMemory.successors.Load(AKey)
ASuccs = value.(*sync.Map)
_, exists = ASuccs.Load(BKey)
if !exists {
t.Errorf("could not find %v in successors of %v", B, A)
}
_, exists = ASuccs.Load(DKey)
if !exists {
t.Errorf("could not find %v in successors of %v", D, A)
Expand Down

0 comments on commit 17c12f1

Please sign in to comment.