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

71 lines
1.7 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
FactoryBot.define do
factory :ci_empty_pipeline, class: Ci::Pipeline do
2017-09-10 17:25:29 +05:30
source :push
2016-09-13 17:45:13 +05:30
ref 'master'
2015-09-25 12:07:36 +05:30
sha '97de212e80737a608d939f648d959671fb0a0142'
2016-09-13 17:45:13 +05:30
status 'pending'
2018-03-17 18:26:18 +05:30
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
factory :ci_pipeline_without_jobs do
2017-08-17 22:00:37 +05:30
after(:build) do |pipeline|
2017-09-10 17:25:29 +05:30
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({}))
2015-09-25 12:07:36 +05:30
end
end
factory :ci_pipeline_with_one_job do
2017-08-17 22:00:37 +05:30
after(:build) do |pipeline|
allow(pipeline).to receive(:ci_yaml_file) do
2017-09-10 17:25:29 +05:30
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({ rspec: { script: "ls" } }))
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
end
end
2017-09-10 17:25:29 +05:30
# Persist merge request head_pipeline_id
# on pipeline factories to avoid circular references
transient { head_pipeline_of nil }
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
transient { config nil }
after(:build) do |pipeline, evaluator|
2017-09-10 17:25:29 +05:30
if evaluator.config
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump(evaluator.config))
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
# Populates pipeline with errors
pipeline.config_processor if evaluator.config
else
pipeline.instance_variable_set(:@ci_yaml_file, File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
end
2015-10-24 18:46:33 +05:30
end
2017-08-17 22:00:37 +05:30
trait :invalid do
config(rspec: nil)
2018-03-17 18:26:18 +05:30
failure_reason :config_error
2017-08-17 22:00:37 +05:30
end
trait :blocked do
status :manual
end
trait :success do
status :success
end
trait :failed do
status :failed
2015-09-25 12:07:36 +05:30
end
2018-03-17 18:26:18 +05:30
trait :protected do
protected true
end
2015-09-25 12:07:36 +05:30
end
end
end