Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2018-03-28 15:40:47 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2018-03-29 11:01:23 +0300
commitae27a47b6e5a27bb16d8f1555207784e34ec2ec1 (patch)
tree137c352d0ec5e555c6061db47a12e3f53d65d6cc /spec/uploaders
parentcb94afc561c08db1b2312020e9d0a3e2f5837494 (diff)
Add Gitlab::ExclusiveLease to ObjectStorage#use_file
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/object_storage_spec.rb24
1 files changed, 24 insertions, 0 deletions
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") }