@@ -29,6 +29,7 @@ import (
29
29
"github.com/operator-framework/operator-controller/internal/catalogmetadata"
30
30
"github.com/operator-framework/operator-controller/internal/conditionsets"
31
31
"github.com/operator-framework/operator-controller/internal/controllers"
32
+ "github.com/operator-framework/operator-controller/internal/packageerrors"
32
33
"github.com/operator-framework/operator-controller/pkg/features"
33
34
)
34
35
@@ -61,7 +62,7 @@ func TestClusterExtensionNonExistentPackage(t *testing.T) {
61
62
t .Log ("By running reconcile" )
62
63
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
63
64
require .Equal (t , ctrl.Result {}, res )
64
- require .EqualError (t , err , fmt . Sprintf ( "no package %q found" , pkgName ))
65
+ require .EqualError (t , err , packageerrors . GenerateError ( pkgName ). Error ( ))
65
66
66
67
t .Log ("By fetching updated cluster extension after reconcile" )
67
68
require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
@@ -75,7 +76,7 @@ func TestClusterExtensionNonExistentPackage(t *testing.T) {
75
76
require .NotNil (t , cond )
76
77
require .Equal (t , metav1 .ConditionFalse , cond .Status )
77
78
require .Equal (t , ocv1alpha1 .ReasonResolutionFailed , cond .Reason )
78
- require .Equal (t , fmt . Sprintf ( "no package %q found" , pkgName ), cond .Message )
79
+ require .Equal (t , packageerrors . GenerateError ( pkgName ). Error ( ), cond .Message )
79
80
80
81
verifyInvariants (ctx , t , reconciler .Client , clusterExtension )
81
82
require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
@@ -103,7 +104,7 @@ func TestClusterExtensionNonExistentVersion(t *testing.T) {
103
104
t .Log ("By running reconcile" )
104
105
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
105
106
require .Equal (t , ctrl.Result {}, res )
106
- require .EqualError (t , err , fmt . Sprintf ( `no package %q matching version "0.50.0" found` , pkgName ))
107
+ require .EqualError (t , err , packageerrors . GenerateVersionError ( pkgName , "0.50.0" ). Error ( ))
107
108
108
109
t .Log ("By fetching updated cluster extension after reconcile" )
109
110
require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
@@ -117,7 +118,7 @@ func TestClusterExtensionNonExistentVersion(t *testing.T) {
117
118
require .NotNil (t , cond )
118
119
require .Equal (t , metav1 .ConditionFalse , cond .Status )
119
120
require .Equal (t , ocv1alpha1 .ReasonResolutionFailed , cond .Reason )
120
- require .Equal (t , fmt . Sprintf ( `no package %q matching version "0.50.0" found` , pkgName ), cond .Message )
121
+ require .Equal (t , packageerrors . GenerateVersionError ( pkgName , "0.50.0" ). Error ( ), cond .Message )
121
122
cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
122
123
require .NotNil (t , cond )
123
124
require .Equal (t , metav1 .ConditionUnknown , cond .Status )
@@ -799,7 +800,7 @@ func TestClusterExtensionVersionNoChannel(t *testing.T) {
799
800
t .Log ("By running reconcile" )
800
801
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
801
802
require .Equal (t , ctrl.Result {}, res )
802
- require .EqualError (t , err , fmt . Sprintf ( "no package %q matching version %q found in channel %q" , pkgName , pkgVer , pkgChan ))
803
+ require .EqualError (t , err , packageerrors . GenerateVersionChannelError ( pkgName , pkgVer , pkgChan ). Error ( ))
803
804
804
805
t .Log ("By fetching updated cluster extension after reconcile" )
805
806
require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
@@ -813,7 +814,7 @@ func TestClusterExtensionVersionNoChannel(t *testing.T) {
813
814
require .NotNil (t , cond )
814
815
require .Equal (t , metav1 .ConditionFalse , cond .Status )
815
816
require .Equal (t , ocv1alpha1 .ReasonResolutionFailed , cond .Reason )
816
- require .Equal (t , fmt . Sprintf ( "no package %q matching version %q found in channel %q" , pkgName , pkgVer , pkgChan ), cond .Message )
817
+ require .Equal (t , packageerrors . GenerateVersionChannelError ( pkgName , pkgVer , pkgChan ). Error ( ), cond .Message )
817
818
cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
818
819
819
820
require .NotNil (t , cond )
@@ -848,7 +849,7 @@ func TestClusterExtensionNoChannel(t *testing.T) {
848
849
t .Log ("By running reconcile" )
849
850
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
850
851
require .Equal (t , ctrl.Result {}, res )
851
- require .EqualError (t , err , fmt . Sprintf ( "no package %q found in channel %q" , pkgName , pkgChan ))
852
+ require .EqualError (t , err , packageerrors . GenerateChannelError ( pkgName , pkgChan ). Error ( ))
852
853
853
854
t .Log ("By fetching updated cluster extension after reconcile" )
854
855
require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
@@ -862,7 +863,7 @@ func TestClusterExtensionNoChannel(t *testing.T) {
862
863
require .NotNil (t , cond )
863
864
require .Equal (t , metav1 .ConditionFalse , cond .Status )
864
865
require .Equal (t , ocv1alpha1 .ReasonResolutionFailed , cond .Reason )
865
- require .Equal (t , fmt . Sprintf ( "no package %q found in channel %q" , pkgName , pkgChan ), cond .Message )
866
+ require .Equal (t , packageerrors . GenerateChannelError ( pkgName , pkgChan ). Error ( ), cond .Message )
866
867
cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
867
868
require .NotNil (t , cond )
868
869
require .Equal (t , metav1 .ConditionUnknown , cond .Status )
@@ -898,7 +899,7 @@ func TestClusterExtensionNoVersion(t *testing.T) {
898
899
t .Log ("By running reconcile" )
899
900
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
900
901
require .Equal (t , ctrl.Result {}, res )
901
- require .EqualError (t , err , fmt . Sprintf ( "no package %q matching version %q found in channel %q" , pkgName , pkgVer , pkgChan ))
902
+ require .EqualError (t , err , packageerrors . GenerateVersionChannelError ( pkgName , pkgVer , pkgChan ). Error ( ))
902
903
903
904
t .Log ("By fetching updated cluster extension after reconcile" )
904
905
require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
@@ -912,7 +913,7 @@ func TestClusterExtensionNoVersion(t *testing.T) {
912
913
require .NotNil (t , cond )
913
914
require .Equal (t , metav1 .ConditionFalse , cond .Status )
914
915
require .Equal (t , ocv1alpha1 .ReasonResolutionFailed , cond .Reason )
915
- require .Equal (t , fmt . Sprintf ( "no package %q matching version %q found in channel %q" , pkgName , pkgVer , pkgChan ), cond .Message )
916
+ require .Equal (t , packageerrors . GenerateVersionChannelError ( pkgName , pkgVer , pkgChan ). Error ( ), cond .Message )
916
917
cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
917
918
require .NotNil (t , cond )
918
919
require .Equal (t , metav1 .ConditionUnknown , cond .Status )
0 commit comments