-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Follow up for #239 + adding list of success codes to SAVABLE_SE…
…TTING_NAMES variable (#388) * Fix: HTTP Code Success check added -> the real fix for 239 Added: 'webhook_http_code_success' should be printed out too for logging/diagnosis * feat: dummy change to make Semantic Pull Request happy again
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
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
56 changes: 56 additions & 0 deletions
56
spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb
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,56 @@ | ||
module PactBroker | ||
module Webhooks | ||
describe WebhookExecutionResult do | ||
subject { WebhookExecutionResult::new(request, response, nil) } | ||
let(:request) do | ||
Net::HTTP::Get.new("http://example.org?foo=bar") | ||
end | ||
|
||
context "When 'webhook_http_code_success' has [200, 201]" do | ||
before do | ||
allow(PactBroker.configuration).to receive(:webhook_http_code_success).and_return([200, 201]) | ||
end | ||
|
||
context "and response is '200'" do | ||
let(:response) { double(code: '200') } | ||
|
||
it "then it should be success" do | ||
expect(subject.success?).to be_truthy | ||
end | ||
end | ||
|
||
context "and response is '400'" do | ||
let(:response) { double(code: '400') } | ||
|
||
it "then it should fail" do | ||
expect(subject.success?).to be_falsey | ||
end | ||
end | ||
end | ||
|
||
|
||
context "When 'webhook_http_code_success' has [400, 401]" do | ||
before do | ||
allow(PactBroker.configuration).to receive(:webhook_http_code_success).and_return([400, 401]) | ||
end | ||
|
||
context "and response is '200'" do | ||
let(:response) { double(code: '200') } | ||
|
||
it "then it should fail" do | ||
expect(subject.success?).to be_falsey | ||
end | ||
end | ||
|
||
context "and response is '400'" do | ||
let(:response) { double(code: '400') } | ||
|
||
it "then it should be success" do | ||
expect(subject.success?).to be_truthy | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |