mirror of
				https://github.com/distribution/distribution.git
				synced 2025-10-31 01:12:48 +00:00 
			
		
		
		
	Merge pull request #1706 from aibaars/registry-size-close
Blobwriter: call BlobWriter.Size after BlobWriter.Close
This commit is contained in:
		| @@ -16,7 +16,7 @@ import ( | ||||
| 	"github.com/docker/distribution/digest" | ||||
| 	"github.com/docker/distribution/reference" | ||||
| 	"github.com/docker/distribution/registry/storage/cache/memory" | ||||
| 	"github.com/docker/distribution/registry/storage/driver/inmemory" | ||||
| 	"github.com/docker/distribution/registry/storage/driver/testdriver" | ||||
| 	"github.com/docker/distribution/testutil" | ||||
| ) | ||||
|  | ||||
| @@ -25,7 +25,7 @@ import ( | ||||
| func TestWriteSeek(t *testing.T) { | ||||
| 	ctx := context.Background() | ||||
| 	imageName, _ := reference.ParseNamed("foo/bar") | ||||
| 	driver := inmemory.New() | ||||
| 	driver := testdriver.New() | ||||
| 	registry, err := NewRegistry(ctx, driver, BlobDescriptorCacheProvider(memory.NewInMemoryBlobDescriptorCacheProvider()), EnableDelete, EnableRedirect) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("error creating registry: %v", err) | ||||
| @@ -43,6 +43,7 @@ func TestWriteSeek(t *testing.T) { | ||||
| 	} | ||||
| 	contents := []byte{1, 2, 3} | ||||
| 	blobUpload.Write(contents) | ||||
| 	blobUpload.Close() | ||||
| 	offset := blobUpload.Size() | ||||
| 	if offset != int64(len(contents)) { | ||||
| 		t.Fatalf("unexpected value for blobUpload offset:  %v != %v", offset, len(contents)) | ||||
| @@ -60,7 +61,7 @@ func TestSimpleBlobUpload(t *testing.T) { | ||||
|  | ||||
| 	ctx := context.Background() | ||||
| 	imageName, _ := reference.ParseNamed("foo/bar") | ||||
| 	driver := inmemory.New() | ||||
| 	driver := testdriver.New() | ||||
| 	registry, err := NewRegistry(ctx, driver, BlobDescriptorCacheProvider(memory.NewInMemoryBlobDescriptorCacheProvider()), EnableDelete, EnableRedirect) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("error creating registry: %v", err) | ||||
| @@ -121,11 +122,12 @@ func TestSimpleBlobUpload(t *testing.T) { | ||||
| 		t.Fatalf("layer data write incomplete") | ||||
| 	} | ||||
|  | ||||
| 	blobUpload.Close() | ||||
|  | ||||
| 	offset := blobUpload.Size() | ||||
| 	if offset != nn { | ||||
| 		t.Fatalf("blobUpload not updated with correct offset: %v != %v", offset, nn) | ||||
| 	} | ||||
| 	blobUpload.Close() | ||||
|  | ||||
| 	// Do a resume, for good fun | ||||
| 	blobUpload, err = bs.Resume(ctx, blobUpload.ID()) | ||||
| @@ -254,7 +256,7 @@ func TestSimpleBlobUpload(t *testing.T) { | ||||
| func TestSimpleBlobRead(t *testing.T) { | ||||
| 	ctx := context.Background() | ||||
| 	imageName, _ := reference.ParseNamed("foo/bar") | ||||
| 	driver := inmemory.New() | ||||
| 	driver := testdriver.New() | ||||
| 	registry, err := NewRegistry(ctx, driver, BlobDescriptorCacheProvider(memory.NewInMemoryBlobDescriptorCacheProvider()), EnableDelete, EnableRedirect) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("error creating registry: %v", err) | ||||
| @@ -366,7 +368,7 @@ func TestBlobMount(t *testing.T) { | ||||
| 	ctx := context.Background() | ||||
| 	imageName, _ := reference.ParseNamed("foo/bar") | ||||
| 	sourceImageName, _ := reference.ParseNamed("foo/source") | ||||
| 	driver := inmemory.New() | ||||
| 	driver := testdriver.New() | ||||
| 	registry, err := NewRegistry(ctx, driver, BlobDescriptorCacheProvider(memory.NewInMemoryBlobDescriptorCacheProvider()), EnableDelete, EnableRedirect) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("error creating registry: %v", err) | ||||
| @@ -517,7 +519,7 @@ func TestBlobMount(t *testing.T) { | ||||
| func TestLayerUploadZeroLength(t *testing.T) { | ||||
| 	ctx := context.Background() | ||||
| 	imageName, _ := reference.ParseNamed("foo/bar") | ||||
| 	driver := inmemory.New() | ||||
| 	driver := testdriver.New() | ||||
| 	registry, err := NewRegistry(ctx, driver, BlobDescriptorCacheProvider(memory.NewInMemoryBlobDescriptorCacheProvider()), EnableDelete, EnableRedirect) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("error creating registry: %v", err) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user