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/bulk_imports/groups/pipelines')
-rw-r--r--spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb7
-rw-r--r--spec/lib/bulk_imports/groups/pipelines/project_entities_pipeline_spec.rb7
-rw-r--r--spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb7
3 files changed, 18 insertions, 3 deletions
diff --git a/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb b/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb
index 36b425f4f12..b470edae2c2 100644
--- a/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe BulkImports::Groups::Pipelines::GroupPipeline do
- describe '#run' do
+ describe '#run', :clean_gitlab_redis_cache do
let_it_be(:user) { create(:user) }
let_it_be(:parent) { create(:group) }
let_it_be(:bulk_import) { create(:bulk_import, user: user) }
@@ -63,6 +63,11 @@ RSpec.describe BulkImports::Groups::Pipelines::GroupPipeline do
expect(imported_group.emails_disabled?).to eq(group_data['emails_disabled'])
expect(imported_group.mentions_disabled?).to eq(group_data['mentions_disabled'])
end
+
+ it 'skips duplicates on pipeline rerun' do
+ expect { subject.run }.to change { Group.count }.by(1)
+ expect { subject.run }.not_to change { Group.count }
+ end
end
describe 'pipeline parts' do
diff --git a/spec/lib/bulk_imports/groups/pipelines/project_entities_pipeline_spec.rb b/spec/lib/bulk_imports/groups/pipelines/project_entities_pipeline_spec.rb
index 0155dc8053e..f7076341f8f 100644
--- a/spec/lib/bulk_imports/groups/pipelines/project_entities_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/groups/pipelines/project_entities_pipeline_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe BulkImports::Groups::Pipelines::ProjectEntitiesPipeline, feature_
subject { described_class.new(context) }
- describe '#run' do
+ describe '#run', :clean_gitlab_redis_cache do
let(:extracted_data) do
BulkImports::Pipeline::ExtractedData.new(data: {
'id' => 'gid://gitlab/Project/1234567',
@@ -49,6 +49,11 @@ RSpec.describe BulkImports::Groups::Pipelines::ProjectEntitiesPipeline, feature_
expect(project_entity.destination_namespace).to eq(destination_group.full_path)
expect(project_entity.source_xid).to eq(1234567)
end
+
+ it 'does not create duplicate entities on rerun' do
+ expect { subject.run }.to change(BulkImports::Entity, :count).by(1)
+ expect { subject.run }.not_to change(BulkImports::Entity, :count)
+ end
end
describe 'pipeline parts' do
diff --git a/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb b/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb
index 6949ac59948..a50fe7ecd4c 100644
--- a/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe BulkImports::Groups::Pipelines::SubgroupEntitiesPipeline do
})
end
- describe '#run' do
+ describe '#run', :clean_gitlab_redis_cache do
before do
allow_next_instance_of(BulkImports::Groups::Extractors::SubgroupsExtractor) do |extractor|
allow(extractor).to receive(:extract).and_return(extracted_data)
@@ -38,6 +38,11 @@ RSpec.describe BulkImports::Groups::Pipelines::SubgroupEntitiesPipeline do
expect(subgroup_entity.destination_name).to eq 'sub-group'
expect(subgroup_entity.parent_id).to eq parent_entity.id
end
+
+ it 'does not create duplicate entities on rerun' do
+ expect { subject.run }.to change(BulkImports::Entity, :count).by(1)
+ expect { subject.run }.not_to change(BulkImports::Entity, :count)
+ end
end
describe '#load' do