debian-mirror-gitlab/spec/factories/ci/pipelines.rb

96 lines
2.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
FactoryBot.define do
2019-12-26 22:10:19 +05:30
# TODO: we can remove this factory in favour of :ci_pipeline
2020-03-09 13:42:32 +05:30
factory :ci_empty_pipeline, class: 'Ci::Pipeline' do
2019-12-21 20:55:43 +05:30
source { :push }
ref { 'master' }
sha { '97de212e80737a608d939f648d959671fb0a0142' }
status { 'pending' }
add_attribute(:protected) { false }
2015-10-24 18:46:33 +05:30
2017-09-10 17:25:29 +05:30
project
2015-09-25 12:07:36 +05:30
2017-09-10 17:25:29 +05:30
# Persist merge request head_pipeline_id
# on pipeline factories to avoid circular references
2019-12-21 20:55:43 +05:30
transient { head_pipeline_of { nil } }
2017-09-10 17:25:29 +05:30
after(:create) do |pipeline, evaluator|
merge_request = evaluator.head_pipeline_of
merge_request&.update(head_pipeline: pipeline)
end
2017-08-17 22:00:37 +05:30
factory :ci_pipeline do
trait :invalid do
2019-12-26 22:10:19 +05:30
yaml_errors { 'invalid YAML' }
2019-12-21 20:55:43 +05:30
failure_reason { :config_error }
2017-08-17 22:00:37 +05:30
end
2019-07-07 11:18:12 +05:30
trait :created do
2019-12-21 20:55:43 +05:30
status { :created }
2019-07-07 11:18:12 +05:30
end
trait :preparing do
2019-12-21 20:55:43 +05:30
status { :preparing }
2019-07-07 11:18:12 +05:30
end
2017-08-17 22:00:37 +05:30
trait :blocked do
2019-12-21 20:55:43 +05:30
status { :manual }
2017-08-17 22:00:37 +05:30
end
2018-12-05 23:21:45 +05:30
trait :scheduled do
2019-12-21 20:55:43 +05:30
status { :scheduled }
2018-12-05 23:21:45 +05:30
end
2017-08-17 22:00:37 +05:30
trait :success do
2019-12-21 20:55:43 +05:30
status { :success }
2017-08-17 22:00:37 +05:30
end
2018-11-18 11:00:15 +05:30
trait :running do
2019-12-21 20:55:43 +05:30
status { :running }
2018-11-18 11:00:15 +05:30
end
2017-08-17 22:00:37 +05:30
trait :failed do
2019-12-21 20:55:43 +05:30
status { :failed }
2015-09-25 12:07:36 +05:30
end
2018-03-17 18:26:18 +05:30
trait :protected do
2019-12-21 20:55:43 +05:30
add_attribute(:protected) { true }
2018-03-17 18:26:18 +05:30
end
2018-11-18 11:00:15 +05:30
trait :with_test_reports do
2019-12-21 20:55:43 +05:30
status { :success }
2018-11-18 11:00:15 +05:30
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ci_build, :test_reports, pipeline: pipeline, project: pipeline.project)
end
end
2018-11-20 20:47:30 +05:30
2019-12-26 22:10:19 +05:30
trait :with_exposed_artifacts do
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ci_build, :artifacts,
pipeline: pipeline,
project: pipeline.project,
options: { artifacts: { expose_as: 'the artifact', paths: ['ci_artifacts.txt'] } })
end
end
2019-05-03 19:53:19 +05:30
trait :with_job do
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ci_build, pipeline: pipeline, project: pipeline.project)
end
end
2018-11-20 20:47:30 +05:30
trait :auto_devops_source do
config_source { Ci::Pipeline.config_sources[:auto_devops_source] }
end
trait :repository_source do
config_source { Ci::Pipeline.config_sources[:repository_source] }
end
2015-09-25 12:07:36 +05:30
end
end
end