@@ -506,6 +506,57 @@ 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+ },
509560 }
510561
511562 for _ , s := range specs {
@@ -577,3 +628,14 @@ func hasError(expectedError string) require.ErrorAssertionFunc {
577628 t .FailNow ()
578629 }
579630}
631+
632+ // hasErrorContaining returns an ErrorAssertionFunc that passes when the error message contains the given substring.
633+ func hasErrorContaining (substring string ) require.ErrorAssertionFunc {
634+ return func (t require.TestingT , actualError error , args ... interface {}) {
635+ if stdt , ok := t .(* testing.T ); ok {
636+ stdt .Helper ()
637+ }
638+ require .Error (t , actualError )
639+ require .Contains (t , actualError .Error (), substring , "expected error to contain %q" , substring )
640+ }
641+ }
0 commit comments