forked from TrueCloudLab/frostfs-s3-gw
[#542] Add test to check delete marker
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
b380d4ab53
commit
9f019c7470
2 changed files with 22 additions and 1 deletions
|
@ -73,7 +73,7 @@ func TestRemoveDeleteMarker(t *testing.T) {
|
||||||
|
|
||||||
checkFound(t, tc, bktName, objName, objInfo.Version())
|
checkFound(t, tc, bktName, objName, objInfo.Version())
|
||||||
deleteObject(t, tc, bktName, objName, deleteMarkerVersion)
|
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")
|
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))
|
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) {
|
func createBucketAndObject(t *testing.T, tc *handlerContext, bktName, objName string) (*data.BucketInfo, *data.ObjectInfo) {
|
||||||
createTestBucket(tc.Context(), t, tc, bktName)
|
createTestBucket(tc.Context(), t, tc, bktName)
|
||||||
bktInfo, err := tc.Layer().GetBucketInfo(tc.Context(), bktName)
|
bktInfo, err := tc.Layer().GetBucketInfo(tc.Context(), bktName)
|
||||||
|
|
|
@ -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)
|
obj.Error = fmt.Errorf("couldn't get random oid: %w", err)
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obj.DeleteMarkVersion = randOID.EncodeToString()
|
||||||
|
|
||||||
newVersion = &data.NodeVersion{
|
newVersion = &data.NodeVersion{
|
||||||
BaseNodeVersion: data.BaseNodeVersion{
|
BaseNodeVersion: data.BaseNodeVersion{
|
||||||
OID: randOID,
|
OID: randOID,
|
||||||
|
|
Loading…
Reference in a new issue