@@ -5,7 +5,6 @@ module CloudController
55 module Blobstore
66 RSpec . describe StorageCliClient do
77 describe 'registry build and lookup' do
8-
98 it 'builds the correct client' do
109 droplets_cfg = Tempfile . new ( [ 'droplets' , '.json' ] )
1110 droplets_cfg . write ( { connection_config : { provider : 'AzureRM' } } . to_json )
@@ -57,8 +56,6 @@ module Blobstore
5756 when :storage_cli_config_file_buildpacks then buildpacks_cfg . path
5857 when :storage_cli_config_file_packages then packages_cfg . path
5958 when :storage_cli_config_file_resource_pool then resource_pool_cfg . path
60- else
61- nil
6259 end
6360 end
6461
@@ -70,12 +67,12 @@ module Blobstore
7067 [ droplets_cfg , buildpacks_cfg , packages_cfg , resource_pool_cfg ] . each ( &:close! )
7168 end
7269
73- def build_client ( rt )
70+ def build_client ( resource_type )
7471 StorageCliClient . build (
7572 connection_config : { provider : 'AzureRM' } ,
7673 directory_key : 'dir-key' ,
7774 root_dir : 'root' ,
78- resource_type : rt
75+ resource_type : resource_type
7976 )
8077 end
8178
@@ -110,23 +107,23 @@ def build_client(rt)
110107 end
111108
112109 it 'raises for unknown resource_type' do
113- expect {
110+ expect do
114111 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/ )
116113 end
117114
118115 it 'raises when file missing/unreadable' do
119116 allow ( config_double ) . to receive ( :get ) . with ( :storage_cli_config_file_packages ) . and_return ( '/no/such/file.json' )
120- expect {
117+ expect do
121118 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/ )
123120 end
124121
125122 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
128125 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/ )
130127 end
131128 end
132129
@@ -157,30 +154,29 @@ def build_client(rt)
157154 end
158155
159156 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 ) ] )
163160
164161 expect ( client . exists? ( 'key' ) ) . to be true
165162 end
166163
167164 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 ) ] )
171168
172169 expect ( client . exists? ( 'key' ) ) . to be false
173170 end
174171
175172 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 ) ] )
179176
180177 expect { client . exists? ( 'key' ) } . to raise_error ( /storage-cli exists failed/ )
181178 end
182179 end
183-
184180 end
185181 end
186182end
0 commit comments