From 8e8bb229327d8df26756e438809a89a882e1c231 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 13 Oct 2021 13:48:54 +1100 Subject: [PATCH] feat: support description of matching_branch and matching_tag consumer version selectors --- lib/pact/pact_broker/pact_selection_description.rb | 6 ++++++ .../pact_broker/pact_selection_description_spec.rb | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/pact/pact_broker/pact_selection_description.rb b/lib/pact/pact_broker/pact_selection_description.rb index 369dc891..6b6a8110 100644 --- a/lib/pact/pact_broker/pact_selection_description.rb +++ b/lib/pact/pact_broker/pact_selection_description.rb @@ -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 diff --git a/spec/lib/pact/pact_broker/pact_selection_description_spec.rb b/spec/lib/pact/pact_broker/pact_selection_description_spec.rb index 98e5e47b..cb93143c 100644 --- a/spec/lib/pact/pact_broker/pact_selection_description_spec.rb +++ b/spec/lib/pact/pact_broker/pact_selection_description_spec.rb @@ -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" }] }