File tree Expand file tree Collapse file tree 2 files changed +33
-16
lines changed
operatorcert/static_tests/common
tests/static_tests/common Expand file tree Collapse file tree 2 files changed +33
-16
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,6 @@ def check_operator_name(bundle: Bundle) -> Iterator[CheckResult]:
4242 other_bundles = all_bundles - {bundle }
4343 other_metadata_operator_names = {x .metadata_operator_name for x in other_bundles }
4444 other_csv_operator_names = {x .csv_operator_name for x in other_bundles }
45- # Count how many unique names are in use in the CSV and annotations.yaml across
46- # all other bundles. Naming is consistent if the count is zero (when the bundle
47- # under test is the only bundle for its operator) or one
48- consistent_metadata_names = len (other_metadata_operator_names ) < 2
49- consistent_csv_names = len (other_csv_operator_names ) < 2
5045 if other_bundles :
5146 yield from _check_consistency (
5247 bundle .metadata_operator_name ,
@@ -65,16 +60,10 @@ def check_operator_name(bundle: Bundle) -> Iterator[CheckResult]:
6560 f"Operator name from annotations.yaml ({ bundle .metadata_operator_name } )"
6661 f" does not match the name defined in the CSV ({ bundle .csv_operator_name } )"
6762 )
68- if consistent_metadata_names and consistent_csv_names :
69- yield Fail (msg )
70- else :
71- yield Warn (msg )
63+ yield Warn (msg ) if other_bundles else Fail (msg )
7264 if bundle .metadata_operator_name != bundle .operator_name :
7365 msg = (
7466 f"Operator name from annotations.yaml ({ bundle .metadata_operator_name } )"
7567 f" does not match the operator's directory name ({ bundle .operator_name } )"
7668 )
77- if consistent_metadata_names :
78- yield Fail (msg )
79- else :
80- yield Warn (msg )
69+ yield Warn (msg ) if other_bundles else Fail (msg )
Original file line number Diff line number Diff line change 141141 ("hello" , "0.0.3" ),
142142 {
143143 (
144- Fail ,
144+ Warn ,
145145 "Operator name from annotations.yaml (foo) does not match"
146146 " the operator's directory name (hello)" ,
147147 ),
148148 (
149- Fail ,
149+ Warn ,
150150 "Operator name from annotations.yaml (foo) does not match"
151151 " the name defined in the CSV (hello)" ,
152152 ),
171171 ("hello" , "0.0.3" ),
172172 {
173173 (
174- Fail ,
174+ Warn ,
175175 "Operator name from annotations.yaml (hello) does not match"
176176 " the name defined in the CSV (foo)" ,
177177 ),
183183 },
184184 id = "Wrong CSV name, consistent bundles" ,
185185 ),
186+ pytest .param (
187+ [
188+ bundle_files (
189+ "hello" ,
190+ "0.0.1" ,
191+ csv = {"metadata" : {"name" : "foo.v0.0.1" }},
192+ ),
193+ bundle_files (
194+ "hello" ,
195+ "0.0.2" ,
196+ csv = {"metadata" : {"name" : "foo.v0.0.2" }},
197+ ),
198+ bundle_files (
199+ "hello" ,
200+ "0.0.3" ,
201+ csv = {"metadata" : {"name" : "foo.v0.0.3" }},
202+ ),
203+ ],
204+ ("hello" , "0.0.3" ),
205+ {
206+ (
207+ Warn ,
208+ "Operator name from annotations.yaml (hello) does not match"
209+ " the name defined in the CSV (foo)" ,
210+ ),
211+ },
212+ id = "Wrong CSV name in all bundles" ,
213+ ),
186214 ],
187215 indirect = False ,
188216)
You can’t perform that action at this time.
0 commit comments