diff --git a/api/handler/delete_test.go b/api/handler/delete_test.go index 1e3ae2b63..a1b75d67c 100644 --- a/api/handler/delete_test.go +++ b/api/handler/delete_test.go @@ -73,7 +73,7 @@ func TestRemoveDeleteMarker(t *testing.T) { checkFound(t, tc, bktName, objName, objInfo.Version()) deleteObject(t, tc, bktName, objName, deleteMarkerVersion) - checkNotFound(t, tc, bktName, objName, emptyVersion) + checkFound(t, tc, bktName, objName, emptyVersion) require.True(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object doesn't exist but should") } @@ -154,6 +154,24 @@ func TestDeleteObjectFromListCache(t *testing.T) { require.False(t, existInMockedNeoFS(tc, bktInfo, objInfo)) } +func TestDeleteObjectCheckMarkerReturn(t *testing.T) { + tc := prepareHandlerContext(t) + + bktName, objName := "bucket-for-removal", "object-to-delete" + createVersionedBucketAndObject(t, tc, bktName, objName) + + deleteMarker := deleteObject(t, tc, bktName, objName, emptyVersion) + + versions := listVersions(t, tc, bktName) + require.Len(t, versions.DeleteMarker, 1) + require.Equal(t, deleteMarker, versions.DeleteMarker[0].VersionID) + + deleteMarker2 := deleteObject(t, tc, bktName, objName, deleteMarker) + versions = listVersions(t, tc, bktName) + require.Len(t, versions.DeleteMarker, 0) + require.Equal(t, deleteMarker, deleteMarker2) +} + func createBucketAndObject(t *testing.T, tc *handlerContext, bktName, objName string) (*data.BucketInfo, *data.ObjectInfo) { createTestBucket(tc.Context(), t, tc, bktName) bktInfo, err := tc.Layer().GetBucketInfo(tc.Context(), bktName) diff --git a/api/layer/layer.go b/api/layer/layer.go index bf73c8431..d6eb70ac9 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -514,6 +514,9 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings obj.Error = fmt.Errorf("couldn't get random oid: %w", err) return obj } + + obj.DeleteMarkVersion = randOID.EncodeToString() + newVersion = &data.NodeVersion{ BaseNodeVersion: data.BaseNodeVersion{ OID: randOID,