Commit aea78559 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '339408-gitlab-migration-pipeline-schedules' into 'master'

Resolve "GitLab Migration - Pipeline schedules"

See merge request gitlab-org/gitlab!74100
parents 4831b598 a7ff59d2
...@@ -26,6 +26,7 @@ RSpec.describe BulkImports::Projects::Stage do ...@@ -26,6 +26,7 @@ RSpec.describe BulkImports::Projects::Stage do
[5, BulkImports::Common::Pipelines::WikiPipeline], [5, BulkImports::Common::Pipelines::WikiPipeline],
[5, BulkImports::Common::Pipelines::UploadsPipeline], [5, BulkImports::Common::Pipelines::UploadsPipeline],
[5, BulkImports::Projects::Pipelines::AutoDevopsPipeline], [5, BulkImports::Projects::Pipelines::AutoDevopsPipeline],
[5, BulkImports::Projects::Pipelines::PipelineSchedulesPipeline],
[6, BulkImports::Common::Pipelines::EntityFinisher] [6, BulkImports::Common::Pipelines::EntityFinisher]
] ]
end end
......
# frozen_string_literal: true
module BulkImports
module Projects
module Pipelines
class PipelineSchedulesPipeline
include NdjsonPipeline
relation_name 'pipeline_schedules'
extractor ::BulkImports::Common::Extractors::NdjsonExtractor, relation: relation
end
end
end
end
...@@ -87,6 +87,10 @@ module BulkImports ...@@ -87,6 +87,10 @@ module BulkImports
pipeline: BulkImports::Projects::Pipelines::AutoDevopsPipeline, pipeline: BulkImports::Projects::Pipelines::AutoDevopsPipeline,
stage: 5 stage: 5
}, },
pipeline_schedules: {
pipeline: BulkImports::Projects::Pipelines::PipelineSchedulesPipeline,
stage: 5
},
finisher: { finisher: {
pipeline: BulkImports::Common::Pipelines::EntityFinisher, pipeline: BulkImports::Common::Pipelines::EntityFinisher,
stage: 6 stage: 6
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Projects::Pipelines::PipelineSchedulesPipeline do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:bulk_import) { create(:bulk_import, user: user) }
let_it_be(:entity) do
create(
:bulk_import_entity,
:project_entity,
project: project,
bulk_import: bulk_import,
source_full_path: 'source/full/path',
destination_name: 'My Destination Project',
destination_namespace: group.full_path
)
end
let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }
let(:schedule_attributes) { {} }
let(:schedule) do
{
'description' => 'test pipeline schedule',
'cron' => '1 1 1 1 1',
'cron_timezone' => 'UTC',
'ref' => 'testref',
'created_at' => '2016-06-13T15:02:47.967Z',
'updated_at' => '2016-06-14T15:02:47.967Z'
}.merge(schedule_attributes)
end
subject(:pipeline) { described_class.new(context) }
before do
group.add_owner(user)
allow_next_instance_of(BulkImports::Common::Extractors::NdjsonExtractor) do |extractor|
allow(extractor).to receive(:extract).and_return(BulkImports::Pipeline::ExtractedData.new(data: [schedule]))
end
pipeline.run
end
it 'imports schedule into destination project' do
expect(project.pipeline_schedules.count).to eq(1)
pipeline_schedule = project.pipeline_schedules.first
schedule.each do |k, v|
expect(pipeline_schedule.send(k)).to eq(v)
end
end
context 'is active' do
let(:schedule_attributes) { { 'active' => true } }
it 'imports the schedule but active is false' do
expect(project.pipeline_schedules.first.active).to be_falsey
end
end
end
...@@ -27,6 +27,7 @@ RSpec.describe BulkImports::Projects::Stage do ...@@ -27,6 +27,7 @@ RSpec.describe BulkImports::Projects::Stage do
[5, BulkImports::Common::Pipelines::WikiPipeline], [5, BulkImports::Common::Pipelines::WikiPipeline],
[5, BulkImports::Common::Pipelines::UploadsPipeline], [5, BulkImports::Common::Pipelines::UploadsPipeline],
[5, BulkImports::Projects::Pipelines::AutoDevopsPipeline], [5, BulkImports::Projects::Pipelines::AutoDevopsPipeline],
[5, BulkImports::Projects::Pipelines::PipelineSchedulesPipeline],
[6, BulkImports::Common::Pipelines::EntityFinisher] [6, BulkImports::Common::Pipelines::EntityFinisher]
] ]
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment