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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 04:45:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 04:45:44 +0300
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/uploaders
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/object_storage_spec.rb76
-rw-r--r--spec/uploaders/terraform/versioned_state_uploader_spec.rb29
2 files changed, 90 insertions, 15 deletions
diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb
index 12c936e154b..c73a9a7aab1 100644
--- a/spec/uploaders/object_storage_spec.rb
+++ b/spec/uploaders/object_storage_spec.rb
@@ -210,6 +210,27 @@ RSpec.describe ObjectStorage do
end
end
+ describe '#use_open_file' do
+ context 'when file is stored locally' do
+ it "returns the file" do
+ expect { |b| uploader.use_open_file(&b) }.to yield_with_args(an_instance_of(ObjectStorage::Concern::OpenFile))
+ end
+ end
+
+ context 'when file is stored remotely' do
+ let(:store) { described_class::Store::REMOTE }
+
+ before do
+ stub_artifacts_object_storage
+ stub_request(:get, %r{s3.amazonaws.com/#{uploader.path}}).to_return(status: 200, body: '')
+ end
+
+ it "returns the file" do
+ expect { |b| uploader.use_open_file(&b) }.to yield_with_args(an_instance_of(ObjectStorage::Concern::OpenFile))
+ end
+ end
+ end
+
describe '#migrate!' do
subject { uploader.migrate!(new_store) }
@@ -414,28 +435,38 @@ RSpec.describe ObjectStorage do
subject { uploader_class.workhorse_authorize(has_length: has_length, maximum_size: maximum_size) }
- shared_examples 'uses local storage' do
+ shared_examples 'returns the maximum size given' do
it "returns temporary path" do
- is_expected.to have_key(:TempPath)
+ expect(subject[:MaximumSize]).to eq(maximum_size)
+ end
+ end
+
+ shared_examples 'uses local storage' do
+ it_behaves_like 'returns the maximum size given' do
+ it "returns temporary path" do
+ is_expected.to have_key(:TempPath)
- expect(subject[:TempPath]).to start_with(uploader_class.root)
- expect(subject[:TempPath]).to include(described_class::TMP_UPLOAD_PATH)
+ expect(subject[:TempPath]).to start_with(uploader_class.root)
+ expect(subject[:TempPath]).to include(described_class::TMP_UPLOAD_PATH)
+ end
end
end
shared_examples 'uses remote storage' do
- it "returns remote store" do
- is_expected.to have_key(:RemoteObject)
+ it_behaves_like 'returns the maximum size given' do
+ it "returns remote store" do
+ is_expected.to have_key(:RemoteObject)
- expect(subject[:RemoteObject]).to have_key(:ID)
- expect(subject[:RemoteObject]).to include(Timeout: a_kind_of(Integer))
- expect(subject[:RemoteObject][:Timeout]).to be(ObjectStorage::DirectUpload::TIMEOUT)
- expect(subject[:RemoteObject]).to have_key(:GetURL)
- expect(subject[:RemoteObject]).to have_key(:DeleteURL)
- expect(subject[:RemoteObject]).to have_key(:StoreURL)
- expect(subject[:RemoteObject][:GetURL]).to include(described_class::TMP_UPLOAD_PATH)
- expect(subject[:RemoteObject][:DeleteURL]).to include(described_class::TMP_UPLOAD_PATH)
- expect(subject[:RemoteObject][:StoreURL]).to include(described_class::TMP_UPLOAD_PATH)
+ expect(subject[:RemoteObject]).to have_key(:ID)
+ expect(subject[:RemoteObject]).to include(Timeout: a_kind_of(Integer))
+ expect(subject[:RemoteObject][:Timeout]).to be(ObjectStorage::DirectUpload::TIMEOUT)
+ expect(subject[:RemoteObject]).to have_key(:GetURL)
+ expect(subject[:RemoteObject]).to have_key(:DeleteURL)
+ expect(subject[:RemoteObject]).to have_key(:StoreURL)
+ expect(subject[:RemoteObject][:GetURL]).to include(described_class::TMP_UPLOAD_PATH)
+ expect(subject[:RemoteObject][:DeleteURL]).to include(described_class::TMP_UPLOAD_PATH)
+ expect(subject[:RemoteObject][:StoreURL]).to include(described_class::TMP_UPLOAD_PATH)
+ end
end
end
@@ -834,4 +865,19 @@ RSpec.describe ObjectStorage do
end
end
end
+
+ describe 'OpenFile' do
+ subject { ObjectStorage::Concern::OpenFile.new(file) }
+
+ let(:file) { double(read: true, size: true, path: true) }
+
+ it 'delegates read and size methods' do
+ expect(subject.read).to eq(true)
+ expect(subject.size).to eq(true)
+ end
+
+ it 'does not delegate path method' do
+ expect { subject.path }.to raise_error(NoMethodError)
+ end
+ end
end
diff --git a/spec/uploaders/terraform/versioned_state_uploader_spec.rb b/spec/uploaders/terraform/versioned_state_uploader_spec.rb
new file mode 100644
index 00000000000..ecc3f943480
--- /dev/null
+++ b/spec/uploaders/terraform/versioned_state_uploader_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Terraform::VersionedStateUploader do
+ subject { model.file }
+
+ let(:model) { create(:terraform_state_version, :with_file) }
+
+ before do
+ stub_terraform_state_object_storage
+ end
+
+ describe '#filename' do
+ it 'contains the UUID of the terraform state record' do
+ expect(subject.filename).to eq("#{model.version}.tfstate")
+ end
+ end
+
+ describe '#store_dir' do
+ it 'hashes the project ID and UUID' do
+ expect(Gitlab::HashedPath).to receive(:new)
+ .with(model.uuid, root_hash: model.project_id)
+ .and_return(:store_dir)
+
+ expect(subject.store_dir).to eq(:store_dir)
+ end
+ end
+end