From ae27a47b6e5a27bb16d8f1555207784e34ec2ec1 Mon Sep 17 00:00:00 2001 From: Alessio Caiazza Date: Wed, 28 Mar 2018 14:40:47 +0200 Subject: Add Gitlab::ExclusiveLease to ObjectStorage#use_file --- spec/uploaders/object_storage_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'spec/uploaders') diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb index 1d406c71955..59e02fecbce 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -308,6 +308,30 @@ describe ObjectStorage do it { is_expected.to eq(remote_directory) } end + context 'when file is in use' do + def when_file_is_in_use + uploader.use_file do + yield + end + end + + it 'cannot migrate' do + when_file_is_in_use do + expect(uploader).not_to receive(:unsafe_migrate!) + + expect { uploader.migrate!(described_class::Store::REMOTE) }.to raise_error('exclusive lease already taken') + end + end + + it 'cannot use_file' do + when_file_is_in_use do + expect(uploader).not_to receive(:unsafe_use_file) + + expect { uploader.use_file }.to raise_error('exclusive lease already taken') + end + end + end + describe '#fog_credentials' do let(:connection) { Settingslogic.new("provider" => "AWS") } -- cgit v1.2.3