zotregistry.io/zot@v1.4.4-0.20231124084042-02a8ed785457/pkg/meta/convert/convert_test.go (about) 1 package convert_test 2 3 import ( 4 "testing" 5 6 ispec "github.com/opencontainers/image-spec/specs-go/v1" 7 . "github.com/smartystreets/goconvey/convey" 8 9 "zotregistry.io/zot/pkg/meta/convert" 10 "zotregistry.io/zot/pkg/meta/proto/gen" 11 ) 12 13 func TestConvertErrors(t *testing.T) { 14 Convey("Errors", t, func() { 15 Convey("GetImageArtifactType", func() { 16 str := convert.GetImageArtifactType(&gen.ImageMeta{MediaType: "bad-media-type"}) 17 So(str, ShouldResemble, "") 18 }) 19 Convey("GetImageManifestSize", func() { 20 size := convert.GetImageManifestSize(&gen.ImageMeta{MediaType: "bad-media-type"}) 21 So(size, ShouldEqual, 0) 22 }) 23 Convey("GetImageDigest", func() { 24 dig := convert.GetImageDigest(&gen.ImageMeta{MediaType: "bad-media-type"}) 25 So(dig.String(), ShouldResemble, "") 26 }) 27 Convey("GetImageDigestStr", func() { 28 digStr := convert.GetImageDigestStr(&gen.ImageMeta{MediaType: "bad-media-type"}) 29 So(digStr, ShouldResemble, "") 30 }) 31 Convey("GetImageAnnotations", func() { 32 annot := convert.GetImageAnnotations(&gen.ImageMeta{MediaType: "bad-media-type"}) 33 So(annot, ShouldBeEmpty) 34 }) 35 Convey("GetImageSubject", func() { 36 subjs := convert.GetImageSubject(&gen.ImageMeta{MediaType: "bad-media-type"}) 37 So(subjs, ShouldBeNil) 38 }) 39 Convey("GetDescriptorRef", func() { 40 ref := convert.GetDescriptorRef(nil) 41 So(ref, ShouldBeNil) 42 }) 43 Convey("GetPlatform", func() { 44 platf := convert.GetPlatform(nil) 45 So(platf, ShouldEqual, ispec.Platform{}) 46 }) 47 Convey("GetPlatformRef", func() { 48 platf := convert.GetPlatform(&gen.Platform{Architecture: "arch"}) 49 So(platf.Architecture, ShouldResemble, "arch") 50 }) 51 Convey("GetImageReferrers", func() { 52 ref := convert.GetImageReferrers(nil) 53 So(ref, ShouldNotBeNil) 54 }) 55 Convey("GetImageSignatures", func() { 56 sigs := convert.GetImageSignatures(nil) 57 So(sigs, ShouldNotBeNil) 58 }) 59 Convey("GetImageStatistics", func() { 60 sigs := convert.GetImageStatistics(nil) 61 So(sigs, ShouldNotBeNil) 62 }) 63 Convey("GetFullImageMetaFromProto", func() { 64 imageMeta := convert.GetFullImageMetaFromProto("tag", nil, nil) 65 So(imageMeta.Digest.String(), ShouldResemble, "") 66 }) 67 Convey("GetFullManifestData", func() { 68 imageMeta := convert.GetFullManifestData(nil, nil) 69 So(len(imageMeta), ShouldEqual, 0) 70 }) 71 }) 72 }