Skip to content

Commit

Permalink
feat(pacts for verification): update wip and pending descriptions for…
Browse files Browse the repository at this point in the history
… wip pacts
  • Loading branch information
bethesque committed May 19, 2022
1 parent 3d9b201 commit b06d447
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/pact_broker/pacts/verifiable_pact_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def inclusion_reason
version_text = head_consumer_tags.size == 1 || branches.size == 1 ? "version" : "versions"
if wip?
# WIP pacts will always have tags, because it is part of the definition of being a WIP pact
"The pact at #{pact_version_url} is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest #{version_text} of #{consumer_name} #{joined_head_consumer_tags_and_branches} and is still in pending state). #{READ_MORE_WIP}"
"The pact at #{pact_version_url} is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest #{version_text} of #{consumer_name} #{joined_head_consumer_tags_and_branches} and it has not yet been successfully verified by #{pending_provider_branch_or_tags_description("a")} when the pact's application version was explicitly specified in the consumer version selectors). #{READ_MORE_WIP}".tap { |it| puts it }
else
criteria_or_criterion = selectors.size > 1 ? "criteria" : "criterion"
version_or_versions = pluralize("the consumer version", selectors.size)
Expand All @@ -40,7 +40,9 @@ def inclusion_reason
end

def pending_reason
if pending?
if pending? && wip?
"This pact is in pending state for this version of #{provider_name} because it was included as a 'work in progress' pact. If this verification fails, it will not cause the overall build to fail. #{READ_MORE_PENDING}"
elsif pending?
"This pact is in pending state for this version of #{provider_name} because a successful verification result for #{pending_provider_branch_or_tags_description("a")} has not yet been published. If this verification fails, it will not cause the overall build to fail. #{READ_MORE_PENDING}"
else
"This pact has previously been successfully verified by #{non_pending_provider_branch_or_tags_description}. If this verification fails, it will fail the build. #{READ_MORE_PENDING}"
Expand Down
32 changes: 29 additions & 3 deletions spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ module Pacts
let(:pending) { true }
let(:pending_provider_tags) { %w[dev] }

its(:inclusion_reason) { is_expected.to include "The pact at http://pact is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest version of Foo tagged with 'feat-x' and is still in pending state)."}
its(:inclusion_reason) { is_expected.to include "The pact at http://pact is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest version of Foo tagged with 'feat-x' and it has not yet been successfully verified by a version of Bar with tag 'dev' when the pact's application version was explicitly specified in the consumer version selectors). Read more at https://docs.pact.io/go/wip"}

context "when the pact is a WIP pact for a consumer branch" do
let(:selectors) { Selectors.create_for_latest_of_each_branch(%w[feat-x feat-y]).resolve(consumer_version) }

its(:inclusion_reason) { is_expected.to include "The pact at http://pact is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest versions of Foo from branches 'feat-x' and 'feat-y' (both have the same content) and is still in pending state)."}
its(:inclusion_reason) { is_expected.to include "The pact at http://pact is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest versions of Foo from branches 'feat-x' and 'feat-y' (both have the same content)"}
end

context "when the pact is a WIP pact for a consumer branch and consumer rags" do
Expand Down Expand Up @@ -217,7 +217,7 @@ module Pacts
end
end

context "when the pact is pending" do
context "when the pact is pending but not wip" do
let(:pending) { true }

context "when there are no non_pending_provider_tags or a provider_branch" do
Expand Down Expand Up @@ -247,6 +247,32 @@ module Pacts
its(:pending_reason) { is_expected.to include "'dev', 'feat-x' and 'feat-y'" }
end
end

context "when the pact is pending and is wip" do
let(:pending) { true }
let(:wip) { true }

context "when there are no non_pending_provider_tags or a provider_branch" do
its(:pending_reason) { is_expected.to include "This pact is in pending state for this version of Bar because it was included as a 'work in progress' pact. If this verification fails, it will not cause the overall build to fail." }
end

context "when there is a provider_branch" do
let(:provider_branch) { "main" }
its(:pending_reason) { is_expected.to include "This pact is in pending state for this version of Bar because it was included as a 'work in progress' pact. If this verification fails, it will not cause the overall build to fail." }
end

context "when there is 1 pending_provider_tag" do
let(:pending_provider_tags) { %w[dev] }

its(:pending_reason) { is_expected.to include "This pact is in pending state for this version of Bar because it was included as a 'work in progress' pact. If this verification fails, it will not cause the overall build to fail." }
end

context "when there are 2 pending_provider_tags" do
let(:pending_provider_tags) { %w[dev feat-x] }

its(:pending_reason) { is_expected.to include "This pact is in pending state for this version of Bar because it was included as a 'work in progress' pact. If this verification fails, it will not cause the overall build to fail." }
end
end
end
end
end
Expand Down

0 comments on commit b06d447

Please sign in to comment.