Skip to content

Commit

Permalink
feat: support description of matching_branch and matching_tag consume…
Browse files Browse the repository at this point in the history
…r version selectors
  • Loading branch information
bethesque committed Oct 13, 2021
1 parent 7ea17af commit 8e8bb22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/pact/pact_broker/pact_selection_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def pact_selection_description(provider, consumer_version_selectors, options, br
elsif selector[:environment]
desc = "currently in #{selector[:environment]}"
desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
elsif selector[:matchingBranch]
desc = "matching current branch"
desc = "#{desc} for #{selector[:consumer]}" if selector[:consumer]
elsif selector[:matchingTag]
desc = "matching tag"
desc = "#{desc} for #{selector[:consumer]}" if selector[:consumer]
else
desc = selector.to_s
end
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/pact/pact_broker/pact_selection_description_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ module PactBroker
it { is_expected.to include "in production" }
end

describe "matching branch" do
let(:consumer_version_selectors) { [{ matchingBranch: true, consumer: "Foo" }] }

it { is_expected.to include "matching current branch for Foo" }
end

describe "matching tag" do
let(:consumer_version_selectors) { [{ matchingTag: true, consumer: "Foo" }] }

it { is_expected.to include "matching tag for Foo" }
end

describe "unknown" do
let(:consumer_version_selectors) { [{ branchPattern: "*foo" }] }

Expand Down

0 comments on commit 8e8bb22

Please sign in to comment.