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/services/bulk_imports')
-rw-r--r--spec/services/bulk_imports/create_service_spec.rb6
-rw-r--r--spec/services/bulk_imports/file_download_service_spec.rb35
2 files changed, 36 insertions, 5 deletions
diff --git a/spec/services/bulk_imports/create_service_spec.rb b/spec/services/bulk_imports/create_service_spec.rb
index 67ec6fee1ae..4b655dd5d6d 100644
--- a/spec/services/bulk_imports/create_service_spec.rb
+++ b/spec/services/bulk_imports/create_service_spec.rb
@@ -10,19 +10,19 @@ RSpec.describe BulkImports::CreateService do
{
source_type: 'group_entity',
source_full_path: 'full/path/to/group1',
- destination_name: 'destination group 1',
+ destination_slug: 'destination group 1',
destination_namespace: 'full/path/to/destination1'
},
{
source_type: 'group_entity',
source_full_path: 'full/path/to/group2',
- destination_name: 'destination group 2',
+ destination_slug: 'destination group 2',
destination_namespace: 'full/path/to/destination2'
},
{
source_type: 'project_entity',
source_full_path: 'full/path/to/project1',
- destination_name: 'destination project 1',
+ destination_slug: 'destination project 1',
destination_namespace: 'full/path/to/destination1'
}
]
diff --git a/spec/services/bulk_imports/file_download_service_spec.rb b/spec/services/bulk_imports/file_download_service_spec.rb
index bd664d6e996..81229cc8431 100644
--- a/spec/services/bulk_imports/file_download_service_spec.rb
+++ b/spec/services/bulk_imports/file_download_service_spec.rb
@@ -136,14 +136,45 @@ RSpec.describe BulkImports::FileDownloadService do
end
context 'when chunk code is not 200' do
- let(:chunk_double) { double('chunk', size: 1000, code: 307) }
+ let(:chunk_double) { double('chunk', size: 1000, code: 500) }
it 'raises an error' do
expect { subject.execute }.to raise_error(
described_class::ServiceError,
- 'File download error 307'
+ 'File download error 500'
)
end
+
+ context 'when chunk code is redirection' do
+ let(:chunk_double) { double('redirection', size: 1000, code: 303) }
+
+ it 'does not write a redirection chunk' do
+ expect { subject.execute }.not_to raise_error
+
+ expect(File.read(filepath)).not_to include('redirection')
+ end
+
+ context 'when redirection chunk appears at a later stage of the download' do
+ it 'raises an error' do
+ another_chunk_double = double('another redirection', size: 1000, code: 303)
+ data_chunk = double('data chunk', size: 1000, code: 200)
+
+ allow_next_instance_of(BulkImports::Clients::HTTP) do |client|
+ allow(client).to receive(:head).and_return(response_double)
+ allow(client)
+ .to receive(:stream)
+ .and_yield(chunk_double)
+ .and_yield(data_chunk)
+ .and_yield(another_chunk_double)
+ end
+
+ expect { subject.execute }.to raise_error(
+ described_class::ServiceError,
+ 'File download error 303'
+ )
+ end
+ end
+ end
end
context 'when file is a symlink' do