Tweak retry policy. 40x errors aren't typically recoverable other than 401s in the case of expired access tokens. Even then, 1 retry is enough

This commit is contained in:
Steven Bazyl committed 2014-01-30 17:27:16 -08:00
1 parent 0c8e067012
commit bfa5225766
2 files changed
+65 -11

No files matched your search

+35 -1
View File
@@ -168,7 +168,7 @@ describe Google::APIClient do
end
end
describe 'when retiries enabled' do
describe 'when retries enabled' do
before do
client.retries = 2
end
@@ -213,6 +213,40 @@ describe Google::APIClient do
)
end
it 'should not attempt multiple token refreshes' do
client.authorization.access_token = '12345'
expect(client.authorization).to receive(:fetch_access_token!).once
@connection = stub_connection do |stub|
stub.get('/foo') do |env|
[401, {}, '{}']
end
end
client.execute(
:uri => 'https://www.gogole.com/foo',
:connection => @connection
)
end
it 'should not retry on client errors' do
count = 0
@connection = stub_connection do |stub|
stub.get('/foo') do |env|
count.should == 0
count += 1
[403, {}, '{}']
end
end
client.execute(
:uri => 'https://www.gogole.com/foo',
:connection => @connection,
:authenticated => false
)
end
it 'should retry on 500 errors' do
client.authorization = nil