Fix #313 - Don't retry uploads marked as final/cancelled and return original error

This commit is contained in:
Steve Bazyl committed 2015-11-30 15:35:18 -08:00
1 parent 8b296b148e
commit 5822e75f34
2 files changed
+26 -8

No files matched your search

+15 -4
View File
@@ -49,7 +49,7 @@ RSpec.describe Google::Apis::Core::UploadIO do
end
it 'should setup length of the stream' do
upload_io = Google::Apis::Core::UploadIO.from_file(file)
upload_io = Google::Apis::Core::UploadIO.from_file(file)
expect(upload_io.length).to eq File.size(file)
end
@@ -60,9 +60,9 @@ RSpec.describe Google::Apis::Core::UploadIO do
context 'with i/o stream' do
let(:io) { StringIO.new 'Hello google' }
it 'should setup default content-type' do
upload_io = Google::Apis::Core::UploadIO.from_io(io)
upload_io = Google::Apis::Core::UploadIO.from_io(io)
expect(upload_io.content_type).to eql Google::Apis::Core::UploadIO::OCTET_STREAM_CONTENT_TYPE
end
@@ -72,7 +72,7 @@ RSpec.describe Google::Apis::Core::UploadIO do
end
it 'should setup length of the stream' do
upload_io = Google::Apis::Core::UploadIO.from_io(io)
upload_io = Google::Apis::Core::UploadIO.from_io(io)
expect(upload_io.length).to eq 'Hello google'.length
end
end
@@ -244,6 +244,17 @@ RSpec.describe Google::Apis::Core::ResumableUploadCommand do
end
end
context 'with non-retriable authorization error on start' do
before(:example) do
stub_request(:post, 'https://www.googleapis.com/zoo/animals')
.to_return(status: [401, 'unauthorized'], headers: { 'X-Goog-Upload-Status' => 'final' }, body: %(unauthorized))
end
it 'should propagate the original error' do
expect { command.execute(client) }.to raise_error Google::Apis::AuthorizationError
end
end
context 'with interruption' do
before(:example) do
stub_request(:post, 'https://www.googleapis.com/zoo/animals')