summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorColby Swandale <colby@taplaboratories.com>2018-01-19 13:35:38 +1100
committerColby Swandale <colby@taplaboratories.com>2018-01-19 13:35:38 +1100
commit724894a4cea4b3f13d9c6a626ed2fdaab88f7474 (patch)
tree9c1e6f46d772f2737310f12dde962bd5e335bd8b /spec
parent26490663ad40e5a1d7f2bf4636c017933a72d272 (diff)
downloadbundler-724894a4cea4b3f13d9c6a626ed2fdaab88f7474.tar.gz
handle gzip corruption errors in the compact index clientcolby/client-index-gzip-error
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/compact_index_client/updater_spec.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/spec/bundler/compact_index_client/updater_spec.rb b/spec/bundler/compact_index_client/updater_spec.rb
index af24e58d5f..fd554a7b0d 100644
--- a/spec/bundler/compact_index_client/updater_spec.rb
+++ b/spec/bundler/compact_index_client/updater_spec.rb
@@ -5,16 +5,16 @@ require "bundler/compact_index_client"
require "bundler/compact_index_client/updater"
RSpec.describe Bundler::CompactIndexClient::Updater do
- subject(:updater) { described_class.new(fetcher) }
-
let(:fetcher) { double(:fetcher) }
+ let(:local_path) { Pathname("/tmp/localpath") }
+ let(:remote_path) { double(:remote_path) }
+
+ subject(:updater) { described_class.new(fetcher) }
context "when the ETag header is missing" do
# Regression test for https://github.com/bundler/bundler/issues/5463
let(:response) { double(:response, :body => "") }
- let(:local_path) { Pathname("/tmp/localpath") }
- let(:remote_path) { double(:remote_path) }
it "MisMatchedChecksumError is raised" do
# Twice: #update retries on failure
@@ -28,10 +28,21 @@ RSpec.describe Bundler::CompactIndexClient::Updater do
end
end
+ context "when the download is corrupt" do
+ let(:response) { double(:response, :body => "") }
+
+ it "raises HTTPError" do
+ expect(response).to receive(:[]).with("Content-Encoding") { "gzip" }
+ expect(fetcher).to receive(:call) { response }
+
+ expect do
+ updater.update(local_path, remote_path)
+ end.to raise_error(Bundler::HTTPError)
+ end
+ end
+
context "when bundler doesn't have permissions on Dir.tmpdir" do
let(:response) { double(:response, :body => "") }
- let(:local_path) { Pathname("/tmp/localpath") }
- let(:remote_path) { double(:remote_path) }
it "Errno::EACCES is raised" do
allow(Dir).to receive(:mktmpdir) { raise Errno::EACCES }