Skip to content

Commit

Permalink
feat(can-i-deploy): support ignoring specific version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 5, 2021
1 parent 6b197a5 commit 2ac5a94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/pact_broker/matrix/parse_can_i_deploy_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ def self.call params
end

if params[:ignore].is_a?(Array)
options[:ignore_selectors] = params[:ignore].collect do | pacticipant_name |
if pacticipant_name.is_a?(String)
PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: pacticipant_name)
options[:ignore_selectors] = params[:ignore].collect do | param |
if param.is_a?(String)
PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: param)
elsif param.is_a?(Hash) && param.key?(:pacticipant)
PactBroker::Matrix::UnresolvedSelector.new({ pacticipant_name: param[:pacticipant], pacticipant_version_number: param[:version] }.compact)
end
end.compact
else
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ module Matrix
end
end

context "with pacticipant selectors to ignore" do
before do
params[:ignore] = [{ pacticipant: "foo" }, { pacticipant: "bar", version: "2" }]
end

its([:ignore_selectors]) do
is_expected.to eq [
PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: "foo"),
PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: "bar", pacticipant_version_number: "2")
]
end
end

context "with a tag" do
let(:params) do
{
Expand Down

0 comments on commit 2ac5a94

Please sign in to comment.