Skip to content

Commit

Permalink
feat(can-i-deploy): only warn about missing version numbers if there …
Browse files Browse the repository at this point in the history
…are no selectors with a version number
  • Loading branch information
bethesque committed Sep 14, 2022
1 parent 7716209 commit ac4e1e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/pact_broker/matrix/deployment_status_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ def bad_practice_warnings

def selector_without_pacticipant_version_number_specified?
# If only the pacticipant name is specified, it can't be a can-i-deploy query, must be a matrix UI query
resolved_selectors
.select(&:specified?)
.reject(&:only_pacticipant_name_specified?)
.reject(&:pacticipant_version_specified_in_original_selector?)
.any?
if resolved_selectors.select(&:specified?).reject(&:only_pacticipant_name_specified?).any?
# There should be at least one selector with a version number specified
resolved_selectors
.select(&:specified?)
.select(&:pacticipant_version_specified_in_original_selector?)
.empty?
else
false
end
end


Expand Down
27 changes: 26 additions & 1 deletion spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ module Matrix
its(:reasons) { is_expected.to eq [IgnoreSelectorDoesNotExist.new(resolved_ignore_selectors.first), PactBroker::Matrix::Successful.new] }
end

context "when there is a selector without a specified pacticipant version number" do
context "when there are no specified selectors with a pacticipant version number" do
let(:resolved_selectors) do
[
ResolvedSelector.new(
Expand All @@ -290,6 +290,31 @@ module Matrix
its(:reasons) { is_expected.to include SelectorWithoutPacticipantVersionNumberSpecified.new }
end

context "when there are only pacticipant names specified" do
let(:resolved_selectors) do
[
ResolvedSelector.new(
pacticipant_id: foo.id,
pacticipant_name: foo.name,
pacticipant_version_number: nil,
pacticipant_version_id: nil,
type: :specified,
original_selector: { pacticipant_name: foo.name }
),
ResolvedSelector.new(
pacticipant_id: bar.id,
pacticipant_name: bar.name,
pacticipant_version_number: nil,
pacticipant_version_id: nil,
type: :specified,
original_selector: { pacticipant_name: bar.name }
)
]
end

its(:reasons) { is_expected.to_not include SelectorWithoutPacticipantVersionNumberSpecified.new }
end

context "when there is no to tag or environment specified and there was only one specified selector" do
let(:resolved_selectors) do
[
Expand Down

0 comments on commit ac4e1e7

Please sign in to comment.