Add ability to commit blob uploads into blobs
This commit is contained in:
parent
f68fbb8028
commit
5d2fe535b4
3 changed files with 46 additions and 1 deletions
|
@ -1,3 +1,6 @@
|
|||
import hashlib
|
||||
import uuid
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
|
@ -530,7 +533,8 @@ def test_torrent_info(pre_oci_model):
|
|||
def test_blob_uploads(pre_oci_model):
|
||||
repository_ref = pre_oci_model.lookup_repository('devtable', 'simple')
|
||||
|
||||
blob_upload = pre_oci_model.create_blob_upload(repository_ref, 'local_us', {'some': 'metadata'})
|
||||
blob_upload = pre_oci_model.create_blob_upload(repository_ref, str(uuid.uuid4()),
|
||||
'local_us', {'some': 'metadata'})
|
||||
assert blob_upload
|
||||
assert blob_upload.storage_metadata == {'some': 'metadata'}
|
||||
assert blob_upload.location_name == 'local_us'
|
||||
|
@ -557,3 +561,17 @@ def test_blob_uploads(pre_oci_model):
|
|||
|
||||
# Ensure it can no longer be found.
|
||||
assert not pre_oci_model.lookup_blob_upload(repository_ref, blob_upload.upload_id)
|
||||
|
||||
|
||||
def test_commit_blob_upload(pre_oci_model):
|
||||
repository_ref = pre_oci_model.lookup_repository('devtable', 'simple')
|
||||
blob_upload = pre_oci_model.create_blob_upload(repository_ref, str(uuid.uuid4()),
|
||||
'local_us', {'some': 'metadata'})
|
||||
|
||||
# Commit the blob upload and make sure it is written as a blob.
|
||||
digest = 'sha256:' + hashlib.sha256('hello').hexdigest()
|
||||
blob = pre_oci_model.commit_blob_upload(blob_upload, digest, 60)
|
||||
assert blob.digest == digest
|
||||
|
||||
# Ensure the upload can no longer be found.
|
||||
assert not pre_oci_model.lookup_blob_upload(repository_ref, blob_upload.upload_id)
|
||||
|
|
Reference in a new issue