@@ -80,6 +80,38 @@ var _ = Describe("Operator Controller Test", func() {
8080 Expect (cond .Message ).To (Equal (fmt .Sprintf ("package '%s' not found" , pkgName )))
8181 })
8282 })
83+ When ("the operator specifies a version range for which there are no bundles" , func () {
84+ var pkgName string
85+ BeforeEach (func () {
86+ By ("initializing cluster state" )
87+ pkgName = fmt .Sprintf ("non-existent-%s" , rand .String (6 ))
88+ operator = & operatorsv1alpha1.Operator {
89+ ObjectMeta : metav1.ObjectMeta {Name : opKey .Name },
90+ Spec : operatorsv1alpha1.OperatorSpec {
91+ PackageName : pkgName ,
92+ Version : ">=0.50.0" ,
93+ },
94+ }
95+ err := cl .Create (ctx , operator )
96+ Expect (err ).NotTo (HaveOccurred ())
97+ })
98+ It ("sets resolution failure status" , func () {
99+ By ("running reconcile" )
100+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
101+ Expect (res ).To (Equal (ctrl.Result {}))
102+ Expect (err ).To (MatchError (fmt .Sprintf ("package '%s' in version range '>=0.50.0' not found" , pkgName )))
103+
104+ By ("fetching updated operator after reconcile" )
105+ Expect (cl .Get (ctx , opKey , operator )).NotTo (HaveOccurred ())
106+
107+ By ("checking the expected conditions" )
108+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
109+ Expect (cond ).NotTo (BeNil ())
110+ Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
111+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionFailed ))
112+ Expect (cond .Message ).To (Equal (fmt .Sprintf ("package '%s' in version range '>=0.50.0' not found" , pkgName )))
113+ })
114+ })
83115 When ("the operator specifies a valid available package" , func () {
84116 const pkgName = "prometheus"
85117 BeforeEach (func () {
0 commit comments