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/file_export_service_spec.rb')
-rw-r--r--spec/services/bulk_imports/file_export_service_spec.rb41
1 files changed, 19 insertions, 22 deletions
diff --git a/spec/services/bulk_imports/file_export_service_spec.rb b/spec/services/bulk_imports/file_export_service_spec.rb
index 94efceff6c6..453fc1d0c0d 100644
--- a/spec/services/bulk_imports/file_export_service_spec.rb
+++ b/spec/services/bulk_imports/file_export_service_spec.rb
@@ -4,39 +4,34 @@ require 'spec_helper'
RSpec.describe BulkImports::FileExportService do
let_it_be(:project) { create(:project) }
- let_it_be(:export_path) { Dir.mktmpdir }
- let_it_be(:relation) { BulkImports::FileTransfer::BaseConfig::UPLOADS_RELATION }
-
- subject(:service) { described_class.new(project, export_path, relation) }
describe '#execute' do
- it 'executes export service and archives exported data' do
- expect_next_instance_of(BulkImports::UploadsExportService) do |service|
- expect(service).to receive(:execute)
- end
+ it 'executes export service and archives exported data for each file relation' do
+ relations = {
+ 'uploads' => BulkImports::UploadsExportService,
+ 'lfs_objects' => BulkImports::LfsObjectsExportService,
+ 'repository' => BulkImports::RepositoryBundleExportService,
+ 'design' => BulkImports::RepositoryBundleExportService
+ }
- expect(subject).to receive(:tar_cf).with(archive: File.join(export_path, 'uploads.tar'), dir: export_path)
+ relations.each do |relation, klass|
+ Dir.mktmpdir do |export_path|
+ service = described_class.new(project, export_path, relation)
- subject.execute
- end
+ expect_next_instance_of(klass) do |service|
+ expect(service).to receive(:execute)
+ end
- context 'when relation is lfs objects' do
- let_it_be(:relation) { BulkImports::FileTransfer::ProjectConfig::LFS_OBJECTS_RELATION }
+ expect(service).to receive(:tar_cf).with(archive: File.join(export_path, "#{relation}.tar"), dir: export_path)
- it 'executes lfs objects export service' do
- expect_next_instance_of(BulkImports::LfsObjectsExportService) do |service|
- expect(service).to receive(:execute)
+ service.execute
end
-
- expect(subject).to receive(:tar_cf).with(archive: File.join(export_path, 'lfs_objects.tar'), dir: export_path)
-
- subject.execute
end
end
context 'when unsupported relation is passed' do
it 'raises an error' do
- service = described_class.new(project, export_path, 'unsupported')
+ service = described_class.new(project, nil, 'unsupported')
expect { service.execute }.to raise_error(BulkImports::Error, 'Unsupported relation export type')
end
@@ -45,7 +40,9 @@ RSpec.describe BulkImports::FileExportService do
describe '#exported_filename' do
it 'returns filename of the exported file' do
- expect(subject.exported_filename).to eq('uploads.tar')
+ service = described_class.new(project, nil, 'uploads')
+
+ expect(service.exported_filename).to eq('uploads.tar')
end
end
end