Skip to content

Commit

Permalink
fixed failed unit test
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 8371bc1 commit ea753f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion content/oci/deletableOci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestDeletableStore(t *testing.T) {

err = s.Delete(ctx, desc)
if err != nil {
t.Errorf("Store.Delete() = %v, wantErr %v", err, true)
t.Errorf("Store.Delete() = %v, wantErr %v", err, nil)
}

exists, err = s.Exists(ctx, desc)
Expand Down
6 changes: 4 additions & 2 deletions internal/graph/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (m *Memory) RemoveFromIndex(ctx context.Context, node ocispec.Descriptor) e
// remove the node from its successors' predecessor list
value, exists := m.successors.Load(nodeKey)
if !exists {
return fmt.Errorf("successors of the node is not found")
return fmt.Errorf("successors of the node %v is not found", node)
}
successors := value.(*sync.Map)
successors.Range(func(key, _ interface{}) bool {
Expand All @@ -144,10 +144,12 @@ func (m *Memory) RemoveFromIndex(ctx context.Context, node ocispec.Descriptor) e
// There is no data consistency issue as long as deletion is not implemented
// for the underlying storage.
func (m *Memory) index(ctx context.Context, node ocispec.Descriptor, successors []ocispec.Descriptor) {
predecessorKey := descriptor.FromOCI(node)
if len(successors) == 0 {
// still create the entry for the node
m.successors.LoadOrStore(predecessorKey, &sync.Map{})
return
}
predecessorKey := descriptor.FromOCI(node)
for _, successor := range successors {
successorKey := descriptor.FromOCI(successor)
// store in m.predecessors, memory.predecessors[successorKey].Store(node)
Expand Down

0 comments on commit ea753f8

Please sign in to comment.