Skip to content

Commit

Permalink
added predecessor test
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <wangxiaoxuan119@gmail.com>
  • Loading branch information
wangxiaoxuan273 committed Nov 29, 2023
1 parent 437bc4b commit 5eff85c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions content/oci/oci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,28 @@ func TestStore_DeleteWithGarbageCollection(t *testing.T) {
t.Errorf("%v should exist in store", node)
}
}

// verify predecessors information
wants := [][]ocispec.Descriptor{
{descs[6]}, // Blob 0
{descs[6]}, // Blob 1
{descs[6]}, // Blob 2
{descs[6]}, // Blob 3
nil, // Blob 4
nil, // Blob 5
{descs[8]}, // Blob 6
nil, // Blob 7
nil, // Blob 8
}
for i, want := range wants {
predecessors, err := s.Predecessors(ctx, descs[i])
if err != nil {
t.Errorf("Store.Predecessors(%d) error = %v", i, err)
}
if !equalDescriptorSet(predecessors, want) {
t.Errorf("Store.Predecessors(%d) = %v, want %v", i, predecessors, want)
}
}
}

func equalDescriptorSet(actual []ocispec.Descriptor, expected []ocispec.Descriptor) bool {
Expand Down

0 comments on commit 5eff85c

Please sign in to comment.