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:
Diffstat (limited to 'spec/lib/object_storage/direct_upload_spec.rb')
-rw-r--r--spec/lib/object_storage/direct_upload_spec.rb45
1 files changed, 43 insertions, 2 deletions
diff --git a/spec/lib/object_storage/direct_upload_spec.rb b/spec/lib/object_storage/direct_upload_spec.rb
index c3890c72852..1c1455e2456 100644
--- a/spec/lib/object_storage/direct_upload_spec.rb
+++ b/spec/lib/object_storage/direct_upload_spec.rb
@@ -2,10 +2,11 @@
require 'spec_helper'
-describe ObjectStorage::DirectUpload do
+RSpec.describe ObjectStorage::DirectUpload do
let(:region) { 'us-east-1' }
let(:path_style) { false }
let(:use_iam_profile) { false }
+ let(:consolidated_settings) { false }
let(:credentials) do
{
provider: 'AWS',
@@ -23,7 +24,7 @@ describe ObjectStorage::DirectUpload do
let(:object_name) { 'tmp/uploads/my-file' }
let(:maximum_size) { 1.gigabyte }
- let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size) }
+ let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size, consolidated_settings: consolidated_settings) }
before do
Fog.unmock!
@@ -60,6 +61,38 @@ describe ObjectStorage::DirectUpload do
end
end
+ describe '#get_url' do
+ subject { described_class.new(credentials, bucket_name, object_name, has_length: true) }
+
+ context 'when AWS is used' do
+ it 'calls the proper method' do
+ expect_next_instance_of(::Fog::Storage, credentials) do |connection|
+ expect(connection).to receive(:get_object_url).once
+ end
+
+ subject.get_url
+ end
+ end
+
+ context 'when Google is used' do
+ let(:credentials) do
+ {
+ provider: 'Google',
+ google_storage_access_key_id: 'GOOGLE_ACCESS_KEY_ID',
+ google_storage_secret_access_key: 'GOOGLE_SECRET_ACCESS_KEY'
+ }
+ end
+
+ it 'calls the proper method' do
+ expect_next_instance_of(::Fog::Storage, credentials) do |connection|
+ expect(connection).to receive(:get_object_https_url).once
+ end
+
+ subject.get_url
+ end
+ end
+ end
+
describe '#to_hash' do
subject { direct_upload.to_hash }
@@ -109,6 +142,14 @@ describe ObjectStorage::DirectUpload do
expect(subject[:UseWorkhorseClient]).to eq(use_iam_profile)
end
end
+
+ context 'when consolidated settings are used' do
+ let(:consolidated_settings) { true }
+
+ it 'enables the Workhorse client' do
+ expect(subject[:UseWorkhorseClient]).to be true
+ end
+ end
end
shared_examples 'a valid Google upload' do