Skip to content

Commit 4308117

Browse files
committed
feat(pacts for verification): update inclusion reason to support fallback tag explanation
1 parent 113180c commit 4308117

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/pact_broker/pacts/selector.rb

+5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ def self.latest_for_tag(tag)
3333
Selector.new(latest: true, tag: tag)
3434
end
3535

36+
def self.latest_for_tag_with_fallback(tag, fallback_tag)
37+
Selector.new(latest: true, tag: tag, fallback_tag: fallback_tag)
38+
end
39+
3640
def self.all_for_tag(tag)
3741
Selector.new(tag: tag)
3842
end
3943

44+
4045
def self.from_hash hash
4146
Selector.new(hash)
4247
end

lib/pact_broker/pacts/verifiable_pact_messages.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ def selector_description selector
129129
if selector.overall_latest?
130130
"latest pact between a consumer and #{provider_name}"
131131
elsif selector.latest_for_tag?
132-
"latest pact for a consumer version tagged '#{selector.tag}'"
132+
if selector.fallback_tag?
133+
"latest pact for a consumer version tagged '#{selector.fallback_tag}' (fallback tag used as no pact was found with tag '#{selector.tag}')"
134+
else
135+
"latest pact for a consumer version tagged '#{selector.tag}'"
136+
end
133137
elsif selector.tag
134138
"pacts for all consumer versions tagged '#{selector.tag}'"
135139
else

spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ module Pacts
4848
its(:inclusion_reason) { is_expected.to include " (all have the same content)" }
4949
end
5050

51+
context "when the pact was selected by the fallback tag" do
52+
let(:selectors) { Selectors.new(Selector.latest_for_tag_with_fallback("feat-x", "master")) }
53+
its(:inclusion_reason) { is_expected.to include "latest pact for a consumer version tagged 'master' (fallback tag used as no pact was found with tag 'feat-x')" }
54+
end
5155

5256
context "when the pact is a WIP pact" do
5357
let(:selectors) { Selectors.create_for_latest_of_each_tag(%w[feat-x]) }

0 commit comments

Comments
 (0)