Skip to content

Commit

Permalink
feat: add pactflow specific message for environment not found when re…
Browse files Browse the repository at this point in the history
…cording a release/deployment
  • Loading branch information
bethesque committed May 18, 2022
1 parent a96eca2 commit 6667cbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/pact_broker/client/deployments/record_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def environment_relation_not_found_error_message
if environment_exists?
"Environment '#{environment_name}' is not an available option for recording a deployment of #{pacticipant_name}."
else
"No environment found with name '#{environment_name}'."
if is_pactflow?
"Environment '#{environment_name}' is not an available option for recording a deployment of #{pacticipant_name}. The environment may not exist, or you may not have the required permissions or team associations to view it."
else
"No environment found with name '#{environment_name}'."
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ module Deployments
expect(subject.success).to be false
expect(subject.message).to include "No environment found with name 'test'. Available options: prod"
end

context "when the server is Pactflow" do
let(:index_headers) { { "Content-Type" => "application/hal+json", "X-Pactflow-Sha" => "123" } }

it "returns a customised message" do
expect(subject.message).to include "Environment 'test' is not an available option for recording a deployment of Foo"
expect(subject.message).to include "permissions"
end
end
end

context "when the environment does exist" do
Expand Down

0 comments on commit 6667cbb

Please sign in to comment.