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/models/bulk_imports/tracker_spec.rb')
-rw-r--r--spec/models/bulk_imports/tracker_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/models/bulk_imports/tracker_spec.rb b/spec/models/bulk_imports/tracker_spec.rb
index 77896105959..0f00aeb9c1d 100644
--- a/spec/models/bulk_imports/tracker_spec.rb
+++ b/spec/models/bulk_imports/tracker_spec.rb
@@ -26,4 +26,60 @@ RSpec.describe BulkImports::Tracker, type: :model do
end
end
end
+
+ describe '.stage_running?' do
+ it 'returns true if there is any unfinished pipeline in the given stage' do
+ tracker = create(:bulk_import_tracker)
+
+ expect(described_class.stage_running?(tracker.entity.id, 0))
+ .to eq(true)
+ end
+
+ it 'returns false if there are no unfinished pipeline in the given stage' do
+ tracker = create(:bulk_import_tracker, :finished)
+
+ expect(described_class.stage_running?(tracker.entity.id, 0))
+ .to eq(false)
+ end
+ end
+
+ describe '.next_pipeline_trackers_for' do
+ let_it_be(:entity) { create(:bulk_import_entity) }
+ let_it_be(:stage_0_tracker) { create(:bulk_import_tracker, :finished, entity: entity) }
+
+ it 'returns empty when all the stages pipelines are finished' do
+ expect(described_class.next_pipeline_trackers_for(entity.id))
+ .to eq([])
+ end
+
+ it 'returns the not started pipeline trackers from the minimum stage number' do
+ stage_1_tracker = create(:bulk_import_tracker, entity: entity, stage: 1)
+ stage_2_tracker = create(:bulk_import_tracker, entity: entity, stage: 2)
+
+ expect(described_class.next_pipeline_trackers_for(entity.id))
+ .to include(stage_1_tracker)
+
+ expect(described_class.next_pipeline_trackers_for(entity.id))
+ .not_to include(stage_2_tracker)
+ end
+ end
+
+ describe '#pipeline_class' do
+ it 'returns the pipeline class' do
+ pipeline_class = BulkImports::Stage.pipelines.first[1]
+ tracker = create(:bulk_import_tracker, pipeline_name: pipeline_class)
+
+ expect(tracker.pipeline_class).to eq(pipeline_class)
+ end
+
+ it 'raises an error when the pipeline is not valid' do
+ tracker = create(:bulk_import_tracker, pipeline_name: 'InexistingPipeline')
+
+ expect { tracker.pipeline_class }
+ .to raise_error(
+ NameError,
+ "'InexistingPipeline' is not a valid BulkImport Pipeline"
+ )
+ end
+ end
end