debian-mirror-gitlab/spec/services/ci/process_pipeline_service_spec.rb

67 lines
1.7 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
require 'spec_helper'
2020-03-09 13:42:32 +05:30
describe Ci::ProcessPipelineService do
2016-09-13 17:45:13 +05:30
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
let(:pipeline) do
create(:ci_empty_pipeline, ref: 'master', project: project)
end
2016-09-13 17:45:13 +05:30
before do
2018-05-09 12:01:36 +05:30
stub_ci_pipeline_to_return_yaml_file
2017-09-10 17:25:29 +05:30
stub_not_protect_default_branch
2017-08-17 22:00:37 +05:30
project.add_developer(user)
2016-09-13 17:45:13 +05:30
end
2017-08-17 22:00:37 +05:30
context 'updates a list of retried builds' do
subject { described_class.retried.order(:id) }
let!(:build_retried) { create_build('build') }
let!(:build) { create_build('build') }
let!(:test) { create_build('test') }
it 'returns unique statuses' do
process_pipeline
expect(all_builds.latest).to contain_exactly(build, test)
expect(all_builds.retried).to contain_exactly(build_retried)
end
end
2020-03-09 13:42:32 +05:30
context 'with a pipeline which has processables with nil scheduling_type', :clean_gitlab_redis_shared_state do
let!(:build1) { create_build('build1') }
let!(:build2) { create_build('build2') }
let!(:build3) { create_build('build3', scheduling_type: :dag) }
let!(:build3_on_build2) { create(:ci_build_need, build: build3, name: 'build2') }
2019-10-12 21:52:04 +05:30
2020-03-09 13:42:32 +05:30
before do
pipeline.processables.update_all(scheduling_type: nil)
2019-10-12 21:52:04 +05:30
end
2020-03-09 13:42:32 +05:30
it 'populates scheduling_type before processing' do
process_pipeline
2019-10-12 21:52:04 +05:30
2020-03-09 13:42:32 +05:30
expect(build1.scheduling_type).to eq('stage')
expect(build2.scheduling_type).to eq('stage')
expect(build3.scheduling_type).to eq('dag')
2019-10-12 21:52:04 +05:30
end
end
2017-08-17 22:00:37 +05:30
def process_pipeline
2020-01-01 13:55:28 +05:30
described_class.new(pipeline).execute
2017-08-17 22:00:37 +05:30
end
def create_build(name, **opts)
create(:ci_build, :created, pipeline: pipeline, name: name, **opts)
end
2018-12-05 23:21:45 +05:30
2020-03-09 13:42:32 +05:30
def all_builds
pipeline.builds.order(:stage_idx, :id)
2018-12-05 23:21:45 +05:30
end
2016-09-13 17:45:13 +05:30
end