forked from pact-foundation/pact_broker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webhook status): display attempts made and attempts remaining in…
… webhook status resource
- Loading branch information
Showing
4 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'pact_broker/webhooks/triggered_webhook' | ||
|
||
module PactBroker | ||
module Webhooks | ||
describe TriggeredWebhook do | ||
let(:status) { TriggeredWebhook::STATUS_SUCCESS } | ||
|
||
subject { TriggeredWebhook.new(status: status) } | ||
|
||
describe "remaining_attempts" do | ||
before do | ||
PactBroker.configuration.webhook_retry_schedule = [1, 1, 1] | ||
allow(subject).to receive(:webhook_executions).and_return([double('execution')]) | ||
end | ||
|
||
its(:number_of_attempts_made) { is_expected.to eq 1 } | ||
|
||
context "when its status is retrying" do | ||
let(:status) { TriggeredWebhook::STATUS_RETRYING } | ||
its(:number_of_attempts_remaining) { is_expected.to eq 3 } | ||
end | ||
|
||
context "when its status is not_run" do | ||
let(:status) { TriggeredWebhook::STATUS_NOT_RUN } | ||
its(:number_of_attempts_remaining) { is_expected.to eq 3 } | ||
end | ||
|
||
context "when its status is success" do | ||
let(:status) { TriggeredWebhook::STATUS_SUCCESS } | ||
its(:number_of_attempts_remaining) { is_expected.to eq 0} | ||
end | ||
|
||
context "when its status is failure" do | ||
let(:status) { TriggeredWebhook::STATUS_FAILURE } | ||
its(:number_of_attempts_remaining) { is_expected.to eq 0} | ||
end | ||
end | ||
end | ||
end | ||
end |