lib/pact_broker/matrix/service.rb in pact_broker-2.101.0 vs lib/pact_broker/matrix/service.rb in pact_broker-2.102.0
- old
+ new
@@ -50,11 +50,11 @@
else
nil
end
end
- # rubocop: disable Metrics/CyclomaticComplexity, Metrics/MethodLength
+ # rubocop: disable Metrics/CyclomaticComplexity
def validate_selectors selectors, options = {}
error_messages = []
selectors.each do | s |
if s[:pacticipant_name].nil?
@@ -71,24 +71,32 @@
unless pacticipant_service.find_pacticipant_by_name(pacticipant_name)
error_messages << "Pacticipant #{pacticipant_name} not found"
end
end
+ if selectors.size == 0
+ error_messages << "Please provide 1 or more version selectors."
+ end
+
+ error_messages + validate_options(options)
+ end
+ # rubocop: enable Metrics/CyclomaticComplexity
+
+ # rubocop: disable Metrics/CyclomaticComplexity
+ def validate_options(options = {})
+ error_messages = []
+
options.fetch(:ignore_selectors, []).each do | s |
if s[:pacticipant_name].nil?
error_messages << "Please specify the pacticipant name to ignore"
else
if s.key?(:pacticipant_version_number) && s.key?(:latest)
error_messages << "A version number and latest flag cannot both be specified for #{s[:pacticipant_name]} to ignore"
end
end
end
- if selectors.size == 0
- error_messages << "Please provide 1 or more version selectors."
- end
-
destination_identifiers = [options[:tag], options[:environment_name], options[:main_branch]&.to_s].compact
if destination_identifiers.size > 1
error_messages << message("errors.validation.cannot_specify_more_than_one_destination_identifier")
end
@@ -105,9 +113,9 @@
error_messages << message("errors.validation.invalid_limit")
end
error_messages
end
- # rubocop: enable Metrics/CyclomaticComplexity, Metrics/MethodLength
+ # rubocop: enable Metrics/CyclomaticComplexity
end
end
end