-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: timeout long running pact content diff requests (#555)
- Loading branch information
Showing
7 changed files
with
61 additions
and
8 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
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
36 changes: 36 additions & 0 deletions
36
spec/lib/pact_broker/api/resources/pact_content_diff_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,36 @@ | ||
require "pact_broker/api/resources/pact_content_diff" | ||
|
||
module PactBroker | ||
module Api | ||
module Resources | ||
describe PactContentDiff do | ||
include_context "stubbed services" | ||
|
||
before do | ||
allow(pact_service).to receive(:find_pact).and_return(pact) | ||
allow(PactBroker::Pacts::Diff).to receive(:new).and_return(diff) | ||
end | ||
|
||
let(:pact) { double("pact") } | ||
let(:diff) { instance_double("PactBroker::Pacts::Diff", process: diff_content) } | ||
let(:diff_content) { "diff_content" } | ||
let(:path) { "/pacts/provider/Provider/consumer/Consumer/version/3/diff/previous-distinct" } | ||
let(:last_response_body) { subject.body } | ||
|
||
subject { get(path) } | ||
|
||
its(:status) { is_expected.to eq 200 } | ||
its(:body) { is_expected.to eq "diff_content" } | ||
|
||
context "when the diff takes too long to generate" do | ||
before do | ||
allow(diff).to receive(:process).and_raise(Timeout::Error) | ||
end | ||
|
||
its(:status) { is_expected.to eq 408 } | ||
its(:body) { is_expected.to eq "" } | ||
end | ||
end | ||
end | ||
end | ||
end |