Skip to content

Commit

Permalink
feat(can i deploy): put out a message while waiting for verification …
Browse files Browse the repository at this point in the history
…results to be published
  • Loading branch information
bethesque committed Apr 4, 2020
1 parent 17b93f3 commit cc1ba5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/pact_broker/client/can_i_deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def fetch_matrix_with_retries
if retry_while_unknown?
check_if_retry_while_unknown_supported(matrix)
if matrix.any_unknown?
$stderr.puts "Waiting for verification results to be published (up to #{wait_time} seconds)"
matrix = Retry.until_truthy_or_max_times(retry_options) do
fetch_matrix
end
Expand Down Expand Up @@ -120,6 +121,10 @@ def retry_tries
options[:retry_while_unknown]
end

def wait_time
retry_interval * retry_tries
end

def check_if_retry_while_unknown_supported(matrix)
if !matrix.supports_unknown_count?
raise PactBroker::Client::Error.new("This version of the Pact Broker does not provide a count of the unknown verification results. Please upgrade your Broker to >= v2.23.4")
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/pact_broker/client/can_i_deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,18 @@ module Client
end

context "when any_unknown? is true" do
before do
allow($stderr).to receive(:puts)
allow(Retry).to receive(:until_truthy_or_max_times)
end

let(:any_unknown) { true }

it "puts a message to stderr" do
expect($stderr).to receive(:puts).with("Waiting for verification results to be published (up to 5 seconds)")
subject
end

it "retries the request" do
expect(Retry).to receive(:until_truthy_or_max_times).with(hash_including(times: 1, sleep: 5, sleep_first: true))
subject
Expand Down

0 comments on commit cc1ba5f

Please sign in to comment.