@@ -144,37 +144,39 @@ def stub_s3_response_for_file(key, exists: true)
144144 end . to raise_error ( FastlaneCore ::Interface ::FastlaneError , 'Path `this-file-does-not-exist.txt` does not exist.' )
145145 end
146146
147- it 'fails if the file already exists on S3 and skip_if_exists:false' do
148- expected_key = 'a62f2225bf70bfaccbc7f1ef2a397836717377de/key'
149- stub_s3_response_for_file ( expected_key )
150-
151- with_tmp_file ( named : 'key' ) do |file_path |
152- expect do
153- run_described_fastlane_action (
154- bucket : test_bucket ,
155- key : 'key' ,
156- file : file_path
157- )
158- end . to raise_error ( FastlaneCore ::Interface ::FastlaneError , "File already exists in S3 bucket #{ test_bucket } at #{ expected_key } " )
147+ context 'when the file already exists on S3' do
148+ it 'fails if skip_if_exists:false' do
149+ expected_key = 'a62f2225bf70bfaccbc7f1ef2a397836717377de/key'
150+ stub_s3_response_for_file ( expected_key )
151+
152+ with_tmp_file ( named : 'key' ) do |file_path |
153+ expect do
154+ run_described_fastlane_action (
155+ bucket : test_bucket ,
156+ key : 'key' ,
157+ file : file_path
158+ )
159+ end . to raise_error ( FastlaneCore ::Interface ::FastlaneError , "File already exists in S3 bucket #{ test_bucket } at #{ expected_key } " )
160+ end
159161 end
160- end
161162
162- it 'just logs if the file already exists on S3 and skip_if_exists:true' do
163- expected_key = 'a62f2225bf70bfaccbc7f1ef2a397836717377de/key'
164- stub_s3_response_for_file ( expected_key )
163+ it 'logs a message without failing if skip_if_exists:true' do
164+ expected_key = 'a62f2225bf70bfaccbc7f1ef2a397836717377de/key'
165+ stub_s3_response_for_file ( expected_key )
165166
166- warnings = [ ]
167- allow ( FastlaneCore ::UI ) . to receive ( :important ) { |message | warnings << message }
167+ warnings = [ ]
168+ allow ( FastlaneCore ::UI ) . to receive ( :important ) { |message | warnings << message }
168169
169- with_tmp_file ( named : 'key' ) do |file_path |
170- key = run_described_fastlane_action (
171- bucket : test_bucket ,
172- key : 'key' ,
173- file : file_path ,
174- skip_if_exists : true
175- )
176- expect ( warnings ) . to eq ( [ "File already exists in S3 bucket #{ test_bucket } at #{ expected_key } . Skipping upload." ] )
177- expect ( key ) . to eq ( expected_key )
170+ with_tmp_file ( named : 'key' ) do |file_path |
171+ key = run_described_fastlane_action (
172+ bucket : test_bucket ,
173+ key : 'key' ,
174+ file : file_path ,
175+ skip_if_exists : true
176+ )
177+ expect ( warnings ) . to eq ( [ "File already exists in S3 bucket #{ test_bucket } at #{ expected_key } . Skipping upload." ] )
178+ expect ( key ) . to eq ( expected_key )
179+ end
178180 end
179181 end
180182 end
0 commit comments