@@ -506,6 +506,71 @@ func TestConvertToModel(t *testing.T) {
506506 })},
507507 },
508508 },
509+ {
510+ name : "Error/BundleImageInvalidPullSpecUnsupportedDigestSsha256" ,
511+ assertion : hasErrorContaining ("invalid image pull spec" ),
512+ cfg : DeclarativeConfig {
513+ Packages : []Package {newTestPackage ("foo" , "alpha" , svgSmallCircle )},
514+ Channels : []Channel {newTestChannel ("foo" , "alpha" , ChannelEntry {Name : testBundleName ("foo" , "0.1.0" )})},
515+ Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" , func (b * Bundle ) {
516+ // Misspelled digest algorithm: ssha256 instead of sha256 (unsupported hash type)
517+ b .Image = "quay.io/operator-framework/foo-bundle@ssha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"
518+ })},
519+ },
520+ },
521+ {
522+ name : "Error/BundleImageInvalidPullSpecUnsupportedDigestMd5" ,
523+ assertion : hasErrorContaining ("invalid image pull spec" ),
524+ cfg : DeclarativeConfig {
525+ Packages : []Package {newTestPackage ("foo" , "alpha" , svgSmallCircle )},
526+ Channels : []Channel {newTestChannel ("foo" , "alpha" , ChannelEntry {Name : testBundleName ("foo" , "0.1.0" )})},
527+ Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" , func (b * Bundle ) {
528+ b .Image = "quay.io/operator-framework/foo-bundle@md5:abcd1234abcd1234abcd1234abcd1234"
529+ })},
530+ },
531+ },
532+ {
533+ name : "Error/BundleRelatedImageInvalidPullSpecSsha256" ,
534+ assertion : hasErrorContaining ("invalid image pull spec" ),
535+ cfg : DeclarativeConfig {
536+ Packages : []Package {newTestPackage ("foo" , "alpha" , svgSmallCircle )},
537+ Channels : []Channel {newTestChannel ("foo" , "alpha" , ChannelEntry {Name : testBundleName ("foo" , "0.1.0" )})},
538+ Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" , func (b * Bundle ) {
539+ b .RelatedImages = []RelatedImage {
540+ {Name : "bundle" , Image : testBundleImage ("foo" , "0.1.0" )},
541+ {Name : "operator" , Image : "quay.io/operator-framework/my-operator@ssha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" },
542+ }
543+ })},
544+ },
545+ },
546+ {
547+ name : "Success/BundleImageValidSha256Digest" ,
548+ assertion : require .NoError ,
549+ cfg : DeclarativeConfig {
550+ Packages : []Package {newTestPackage ("foo" , "alpha" , svgSmallCircle )},
551+ Channels : []Channel {newTestChannel ("foo" , "alpha" , ChannelEntry {Name : testBundleName ("foo" , "0.1.0" )})},
552+ Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" , func (b * Bundle ) {
553+ b .Image = "quay.io/operator-framework/foo-bundle@sha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"
554+ b .RelatedImages = []RelatedImage {
555+ {Name : "bundle" , Image : "quay.io/operator-framework/foo-bundle@sha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" },
556+ }
557+ })},
558+ },
559+ },
560+ {
561+ name : "Success/BundleImageValidTagWithDigest" ,
562+ assertion : require .NoError ,
563+ cfg : DeclarativeConfig {
564+ Packages : []Package {newTestPackage ("foo" , "alpha" , svgSmallCircle )},
565+ Channels : []Channel {newTestChannel ("foo" , "alpha" , ChannelEntry {Name : testBundleName ("foo" , "0.1.0" )})},
566+ Bundles : []Bundle {newTestBundle ("foo" , "0.1.0" , func (b * Bundle ) {
567+ b .Image = "quay.io/operator-framework/foo-bundle:v0.1.0@sha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"
568+ b .RelatedImages = []RelatedImage {
569+ {Name : "bundle" , Image : "quay.io/operator-framework/foo-bundle:v0.1.0@sha256:abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234" },
570+ }
571+ })},
572+ },
573+ },
509574 }
510575
511576 for _ , s := range specs {
@@ -577,3 +642,14 @@ func hasError(expectedError string) require.ErrorAssertionFunc {
577642 t .FailNow ()
578643 }
579644}
645+
646+ // hasErrorContaining returns an ErrorAssertionFunc that passes when the error message contains the given substring.
647+ func hasErrorContaining (substring string ) require.ErrorAssertionFunc {
648+ return func (t require.TestingT , actualError error , args ... interface {}) {
649+ if stdt , ok := t .(* testing.T ); ok {
650+ stdt .Helper ()
651+ }
652+ require .Error (t , actualError )
653+ require .Contains (t , actualError .Error (), substring , "expected error to contain %q" , substring )
654+ }
655+ }
0 commit comments