@@ -39,6 +39,7 @@ import (
3939 "github.com/containerd/containerd/pkg/testutil"
4040 "github.com/gotestyourself/gotestyourself/assert"
4141 "github.com/opencontainers/go-digest"
42+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
4243)
4344
4445type memoryLabelStore struct {
@@ -108,7 +109,7 @@ func TestContentWriter(t *testing.T) {
108109 t .Fatal ("ingest dir should be created" , err )
109110 }
110111
111- cw , err := cs .Writer (ctx , "myref" , 0 , "" )
112+ cw , err := cs .Writer (ctx , content . WithRef ( "myref" ) )
112113 if err != nil {
113114 t .Fatal (err )
114115 }
@@ -117,13 +118,13 @@ func TestContentWriter(t *testing.T) {
117118 }
118119
119120 // reopen, so we can test things
120- cw , err = cs .Writer (ctx , "myref" , 0 , "" )
121+ cw , err = cs .Writer (ctx , content . WithRef ( "myref" ) )
121122 if err != nil {
122123 t .Fatal (err )
123124 }
124125
125126 // make sure that second resume also fails
126- if _ , err = cs .Writer (ctx , "myref" , 0 , "" ); err == nil {
127+ if _ , err = cs .Writer (ctx , content . WithRef ( "myref" ) ); err == nil {
127128 // TODO(stevvooe): This also works across processes. Need to find a way
128129 // to test that, as well.
129130 t .Fatal ("no error on second resume" )
@@ -166,7 +167,7 @@ func TestContentWriter(t *testing.T) {
166167 t .Fatal (err )
167168 }
168169
169- cw , err = cs .Writer (ctx , "aref" , 0 , "" )
170+ cw , err = cs .Writer (ctx , content . WithRef ( "aref" ) )
170171 if err != nil {
171172 t .Fatal (err )
172173 }
@@ -346,7 +347,8 @@ func checkBlobPath(t *testing.T, cs content.Store, dgst digest.Digest) string {
346347}
347348
348349func checkWrite (ctx context.Context , t checker , cs content.Store , dgst digest.Digest , p []byte ) digest.Digest {
349- if err := content .WriteBlob (ctx , cs , dgst .String (), bytes .NewReader (p ), int64 (len (p )), dgst ); err != nil {
350+ if err := content .WriteBlob (ctx , cs , dgst .String (), bytes .NewReader (p ),
351+ ocispec.Descriptor {Size : int64 (len (p )), Digest : dgst }); err != nil {
350352 t .Fatal (err )
351353 }
352354
@@ -365,25 +367,25 @@ func TestWriterTruncateRecoversFromIncompleteWrite(t *testing.T) {
365367 defer cancel ()
366368
367369 ref := "ref"
368- content := []byte ("this is the content" )
369- total := int64 (len (content ))
370+ contentB := []byte ("this is the content" )
371+ total := int64 (len (contentB ))
370372 setupIncompleteWrite (ctx , t , cs , ref , total )
371373
372- writer , err := cs .Writer (ctx , ref , total , "" )
374+ writer , err := cs .Writer (ctx , content . WithRef ( ref ), content . WithDescriptor (ocispec. Descriptor { Size : total }) )
373375 assert .NilError (t , err )
374376
375377 assert .NilError (t , writer .Truncate (0 ))
376378
377- _ , err = writer .Write (content )
379+ _ , err = writer .Write (contentB )
378380 assert .NilError (t , err )
379381
380- dgst := digest .FromBytes (content )
382+ dgst := digest .FromBytes (contentB )
381383 err = writer .Commit (ctx , total , dgst )
382384 assert .NilError (t , err )
383385}
384386
385387func setupIncompleteWrite (ctx context.Context , t * testing.T , cs content.Store , ref string , total int64 ) {
386- writer , err := cs .Writer (ctx , ref , total , "" )
388+ writer , err := cs .Writer (ctx , content . WithRef ( ref ), content . WithDescriptor (ocispec. Descriptor { Size : total }) )
387389 assert .NilError (t , err )
388390
389391 _ , err = writer .Write ([]byte ("bad data" ))
0 commit comments