@@ -75,7 +75,7 @@ func (r *mockRepository) GetByTag(tag string, options ...distribution.ManifestSe
75
75
type mockBlobStore struct {
76
76
distribution.BlobStore
77
77
78
- statErr , serveErr error
78
+ statErr , serveErr , openErr error
79
79
}
80
80
81
81
func (r * mockBlobStore ) Stat (ctx context.Context , dgst digest.Digest ) (distribution.Descriptor , error ) {
@@ -86,6 +86,10 @@ func (r *mockBlobStore) ServeBlob(ctx context.Context, w http.ResponseWriter, re
86
86
return r .serveErr
87
87
}
88
88
89
+ func (r * mockBlobStore ) Open (ctx context.Context , dgst digest.Digest ) (distribution.ReadSeekCloser , error ) {
90
+ return nil , r .openErr
91
+ }
92
+
89
93
func TestSchema1ToImage (t * testing.T ) {
90
94
m := & schema1.SignedManifest {}
91
95
if err := json .Unmarshal ([]byte (etcdManifest ), m ); err != nil {
@@ -284,6 +288,7 @@ func TestRetryFailure(t *testing.T) {
284
288
blobs : & mockBlobStore {
285
289
serveErr : errcode .ErrorCodeUnauthorized ,
286
290
statErr : errcode .ErrorCodeUnauthorized ,
291
+ openErr : errcode .ErrorCodeUnauthorized ,
287
292
},
288
293
}
289
294
r = NewRetryRepository (repo , 4 , 0 ).(* retryRepository )
@@ -326,4 +331,8 @@ func TestRetryFailure(t *testing.T) {
326
331
if err := b .ServeBlob (nil , nil , nil , digest .Digest ("foo" )); err != repo .getErr || r .retries != 0 {
327
332
t .Fatalf ("unexpected: %v %v %#v" , m , err , r )
328
333
}
334
+ r .retries = 2
335
+ if _ , err := b .Open (nil , digest .Digest ("foo" )); err != repo .getErr || r .retries != 0 {
336
+ t .Fatalf ("unexpected: %v %v %#v" , m , err , r )
337
+ }
329
338
}
0 commit comments