Skip to content

Commit

Permalink
fix(v1/random): set MediaType in randomIndex.manifest (#1343)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Stroczynski <estroz@slim.ai>
  • Loading branch information
estroz and Eric Stroczynski authored Apr 13, 2022
1 parent f1b065c commit 610f826
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/v1/random/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type randomIndex struct {
func Index(byteSize, layers, count int64) (v1.ImageIndex, error) {
manifest := v1.IndexManifest{
SchemaVersion: 2,
MediaType: types.OCIImageIndex,
Manifests: []v1.Descriptor{},
}

Expand Down Expand Up @@ -73,7 +74,7 @@ func Index(byteSize, layers, count int64) (v1.ImageIndex, error) {
}

func (i *randomIndex) MediaType() (types.MediaType, error) {
return types.OCIImageIndex, nil
return i.manifest.MediaType, nil
}

func (i *randomIndex) Digest() (v1.Hash, error) {
Expand Down
9 changes: 9 additions & 0 deletions pkg/v1/random/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,13 @@ func TestRandomIndex(t *testing.T) {
if got, want := mt, types.OCIImageIndex; got != want {
t.Errorf("MediaType(): got: %v, want: %v", got, want)
}

man, err := ii.IndexManifest()
if err != nil {
t.Errorf("IndexManifest(): unexpected err: %v", err)
}

if got, want := man.MediaType, types.OCIImageIndex; got != want {
t.Errorf("MediaType: got: %v, want: %v", got, want)
}
}

0 comments on commit 610f826

Please sign in to comment.