berkshelf-api-client 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ae52121b8a453496aed06a502cf6f1a04db8064
|
4
|
+
data.tar.gz: acc3706fad1bf844627501bd60f2ccd1ddccbf0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9844b0690e99f908e45293c2ba693768379bb40d49097566d47a54fba3efa170dd9139a09bc2c97b3cb1e76c48d576f81e458c42a09dda2c59d938ce4f3a3ba1
|
7
|
+
data.tar.gz: e9ad01a91d38dfd169be53795fe351491eda4b0b6a8ab4b452aa6797940cae8aee2d63eec3caf0e9e6211e0f903e345d2ee8976aaff3e32fd3e6695c29f69f2b
|
data/.travis.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
|
3
3
|
module Berkshelf::APIClient
|
4
|
+
require_relative 'errors'
|
5
|
+
|
4
6
|
class Connection < Faraday::Connection
|
5
7
|
# @return [String]
|
6
8
|
attr_reader :url
|
@@ -36,7 +38,10 @@ module Berkshelf::APIClient
|
|
36
38
|
b.request :retry,
|
37
39
|
max: self.retries,
|
38
40
|
interval: self.retry_interval,
|
39
|
-
exceptions: [
|
41
|
+
exceptions: [
|
42
|
+
Faraday::Error::TimeoutError,
|
43
|
+
Errno::ETIMEDOUT
|
44
|
+
]
|
40
45
|
|
41
46
|
b.adapter :net_http
|
42
47
|
end
|
@@ -62,14 +67,16 @@ module Berkshelf::APIClient
|
|
62
67
|
end
|
63
68
|
end
|
64
69
|
when 404
|
65
|
-
raise
|
70
|
+
raise ServiceNotFound, "service not found at: #{url}"
|
66
71
|
when 500..504
|
67
|
-
raise
|
72
|
+
raise ServiceUnavaiable, "service unavailable at: #{url}"
|
68
73
|
else
|
69
|
-
raise
|
74
|
+
raise BadResponse, "bad response #{response.inspect}"
|
70
75
|
end
|
71
76
|
rescue Faraday::Error::TimeoutError, Errno::ETIMEDOUT
|
72
|
-
raise
|
77
|
+
raise TimeoutError, "Unable to connect to: #{url}"
|
78
|
+
rescue Faraday::Error::ConnectionFailed => ex
|
79
|
+
raise ServiceUnavaiable, ex
|
73
80
|
end
|
74
81
|
end
|
75
82
|
end
|
@@ -53,5 +53,15 @@ describe Berkshelf::APIClient::Connection do
|
|
53
53
|
expect(remote.location_type).to_not be_nil
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
context "when the connection to the service fails" do
|
58
|
+
before do
|
59
|
+
instance.should_receive(:get).and_raise(Faraday::Error::ConnectionFailed.new(StandardError))
|
60
|
+
end
|
61
|
+
|
62
|
+
it "raises a Berkshelf::APIClient::ServiceUnavaiable" do
|
63
|
+
expect { subject }.to raise_error(Berkshelf::APIClient::ServiceUnavaiable)
|
64
|
+
end
|
65
|
+
end
|
56
66
|
end
|
57
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-12-
|
13
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|