diff --git a/lib/pact_broker/pacts/verifiable_pact_messages.rb b/lib/pact_broker/pacts/verifiable_pact_messages.rb index 099af8c03..d26f4df17 100644 --- a/lib/pact_broker/pacts/verifiable_pact_messages.rb +++ b/lib/pact_broker/pacts/verifiable_pact_messages.rb @@ -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) @@ -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}" diff --git a/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb b/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb index d6931c2a6..6127416a5 100644 --- a/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +++ b/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb @@ -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 @@ -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 @@ -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