@@ -5,7 +5,6 @@ module CloudController
5
5
module Blobstore
6
6
RSpec . describe StorageCliClient do
7
7
describe 'registry build and lookup' do
8
-
9
8
it 'builds the correct client' do
10
9
droplets_cfg = Tempfile . new ( [ 'droplets' , '.json' ] )
11
10
droplets_cfg . write ( { connection_config : { provider : 'AzureRM' } } . to_json )
@@ -57,8 +56,6 @@ module Blobstore
57
56
when :storage_cli_config_file_buildpacks then buildpacks_cfg . path
58
57
when :storage_cli_config_file_packages then packages_cfg . path
59
58
when :storage_cli_config_file_resource_pool then resource_pool_cfg . path
60
- else
61
- nil
62
59
end
63
60
end
64
61
@@ -70,12 +67,12 @@ module Blobstore
70
67
[ droplets_cfg , buildpacks_cfg , packages_cfg , resource_pool_cfg ] . each ( &:close! )
71
68
end
72
69
73
- def build_client ( rt )
70
+ def build_client ( resource_type )
74
71
StorageCliClient . build (
75
72
connection_config : { provider : 'AzureRM' } ,
76
73
directory_key : 'dir-key' ,
77
74
root_dir : 'root' ,
78
- resource_type : rt
75
+ resource_type : resource_type
79
76
)
80
77
end
81
78
@@ -110,23 +107,23 @@ def build_client(rt)
110
107
end
111
108
112
109
it 'raises for unknown resource_type' do
113
- expect {
110
+ expect do
114
111
build_client ( 'nope' )
115
- } . to raise_error ( CloudController ::Blobstore ::BlobstoreError , /Unknown resource_type: nope/ )
112
+ end . to raise_error ( CloudController ::Blobstore ::BlobstoreError , /Unknown resource_type: nope/ )
116
113
end
117
114
118
115
it 'raises when file missing/unreadable' do
119
116
allow ( config_double ) . to receive ( :get ) . with ( :storage_cli_config_file_packages ) . and_return ( '/no/such/file.json' )
120
- expect {
117
+ expect do
121
118
build_client ( 'packages' )
122
- } . to raise_error ( CloudController ::Blobstore ::BlobstoreError , /not found or not readable/ )
119
+ end . to raise_error ( CloudController ::Blobstore ::BlobstoreError , /not found or not readable/ )
123
120
end
124
121
125
122
it 'raises when YAML load fails' do
126
- File . write ( packages_cfg . path , " { this is: [not, valid }" )
127
- expect {
123
+ File . write ( packages_cfg . path , ' { this is: [not, valid }' )
124
+ expect do
128
125
build_client ( 'packages' )
129
- } . to raise_error ( CloudController ::Blobstore ::BlobstoreError , /Failed to load storage-cli config/ )
126
+ end . to raise_error ( CloudController ::Blobstore ::BlobstoreError , /Failed to load storage-cli config/ )
130
127
end
131
128
end
132
129
@@ -157,30 +154,29 @@ def build_client(rt)
157
154
end
158
155
159
156
it 'returns true on exitstatus 0' do
160
- expect ( Open3 ) . to receive ( :capture3 )
161
- . with ( kind_of ( String ) , '-c' , droplets_cfg . path , 'exists' , kind_of ( String ) )
162
- . and_return ( [ '' , '' , instance_double ( Process ::Status , success? : true , exitstatus : 0 ) ] )
157
+ expect ( Open3 ) . to receive ( :capture3 ) .
158
+ with ( kind_of ( String ) , '-c' , droplets_cfg . path , 'exists' , kind_of ( String ) ) .
159
+ and_return ( [ '' , '' , instance_double ( Process ::Status , success? : true , exitstatus : 0 ) ] )
163
160
164
161
expect ( client . exists? ( 'key' ) ) . to be true
165
162
end
166
163
167
164
it 'returns false on exitstatus 3' do
168
- expect ( Open3 ) . to receive ( :capture3 )
169
- . with ( kind_of ( String ) , '-c' , droplets_cfg . path , 'exists' , kind_of ( String ) )
170
- . and_return ( [ '' , '' , instance_double ( Process ::Status , success? : false , exitstatus : 3 ) ] )
165
+ expect ( Open3 ) . to receive ( :capture3 ) .
166
+ with ( kind_of ( String ) , '-c' , droplets_cfg . path , 'exists' , kind_of ( String ) ) .
167
+ and_return ( [ '' , '' , instance_double ( Process ::Status , success? : false , exitstatus : 3 ) ] )
171
168
172
169
expect ( client . exists? ( 'key' ) ) . to be false
173
170
end
174
171
175
172
it 'raises for other non-zero exit codes' do
176
- expect ( Open3 ) . to receive ( :capture3 )
177
- . with ( kind_of ( String ) , '-c' , droplets_cfg . path , 'exists' , kind_of ( String ) )
178
- . and_return ( [ '' , 'boom' , instance_double ( Process ::Status , success? : false , exitstatus : 2 ) ] )
173
+ expect ( Open3 ) . to receive ( :capture3 ) .
174
+ with ( kind_of ( String ) , '-c' , droplets_cfg . path , 'exists' , kind_of ( String ) ) .
175
+ and_return ( [ '' , 'boom' , instance_double ( Process ::Status , success? : false , exitstatus : 2 ) ] )
179
176
180
177
expect { client . exists? ( 'key' ) } . to raise_error ( /storage-cli exists failed/ )
181
178
end
182
179
end
183
-
184
180
end
185
181
end
186
182
end
0 commit comments