diff options
Diffstat (limited to 'spec/factories/ci')
-rw-r--r-- | spec/factories/ci/builds.rb | 39 | ||||
-rw-r--r-- | spec/factories/ci/group_variables.rb | 12 | ||||
-rw-r--r-- | spec/factories/ci/pipeline_schedule.rb (renamed from spec/factories/ci/trigger_schedules.rb) | 13 | ||||
-rw-r--r-- | spec/factories/ci/pipeline_schedule_variables.rb | 8 | ||||
-rw-r--r-- | spec/factories/ci/pipeline_variable_variables.rb | 8 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 33 | ||||
-rw-r--r-- | spec/factories/ci/runner_projects.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/stages.rb | 8 | ||||
-rw-r--r-- | spec/factories/ci/trigger_requests.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/triggers.rb | 7 | ||||
-rw-r--r-- | spec/factories/ci/variables.rb | 6 |
11 files changed, 105 insertions, 37 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index b62def83ee4..5bba1dec7db 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -64,7 +64,8 @@ FactoryGirl.define do trait :teardown_environment do environment 'staging' options environment: { name: 'staging', - action: 'stop' } + action: 'stop', + url: 'http://staging.example.com/$CI_JOB_NAME' } end trait :allowed_to_fail do @@ -79,6 +80,23 @@ FactoryGirl.define do manual end + trait :retryable do + success + end + + trait :retried do + retried true + end + + trait :cancelable do + pending + end + + trait :erasable do + success + artifacts + end + trait :tags do tag_list [:docker, :ruby] end @@ -92,7 +110,7 @@ FactoryGirl.define do end after(:build) do |build, evaluator| - build.project = build.pipeline.project + build.project ||= build.pipeline.project end factory :ci_not_started_build do @@ -115,6 +133,16 @@ FactoryGirl.define do end end + trait :unicode_trace do + after(:create) do |build, evaluator| + trace = File.binread( + File.expand_path( + Rails.root.join('spec/fixtures/trace/ansi-sequence-and-unicode'))) + + build.trace.set(trace) + end + end + trait :erased do erased_at Time.now erased_by factory: :user @@ -170,8 +198,8 @@ FactoryGirl.define do trait :extended_options do options do { - image: 'ruby:2.1', - services: ['postgres'], + image: { name: 'ruby:2.1', entrypoint: '/bin/sh' }, + services: ['postgres', { name: 'docker:dind', entrypoint: '/bin/sh', command: 'sleep 30', alias: 'docker' }], after_script: %w(ls date), artifacts: { name: 'artifacts_file', @@ -183,7 +211,8 @@ FactoryGirl.define do cache: { key: 'cache_key', untracked: false, - paths: ['vendor/*'] + paths: ['vendor/*'], + policy: 'pull-push' } } end diff --git a/spec/factories/ci/group_variables.rb b/spec/factories/ci/group_variables.rb new file mode 100644 index 00000000000..565ced9eb1a --- /dev/null +++ b/spec/factories/ci/group_variables.rb @@ -0,0 +1,12 @@ +FactoryGirl.define do + factory :ci_group_variable, class: Ci::GroupVariable do + sequence(:key) { |n| "VARIABLE_#{n}" } + value 'VARIABLE_VALUE' + + trait(:protected) do + protected true + end + + group factory: :group + end +end diff --git a/spec/factories/ci/trigger_schedules.rb b/spec/factories/ci/pipeline_schedule.rb index 2390706fa41..564fef6833b 100644 --- a/spec/factories/ci/trigger_schedules.rb +++ b/spec/factories/ci/pipeline_schedule.rb @@ -1,14 +1,11 @@ FactoryGirl.define do - factory :ci_trigger_schedule, class: Ci::TriggerSchedule do - trigger factory: :ci_trigger_for_trigger_schedule + factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do cron '0 1 * * *' cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE ref 'master' active true - - after(:build) do |trigger_schedule, evaluator| - trigger_schedule.project ||= trigger_schedule.trigger.project - end + description "pipeline schedule" + project trait :nightly do cron '0 1 * * *' @@ -24,5 +21,9 @@ FactoryGirl.define do cron '0 1 22 * *' cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE end + + trait :inactive do + active false + end end end diff --git a/spec/factories/ci/pipeline_schedule_variables.rb b/spec/factories/ci/pipeline_schedule_variables.rb new file mode 100644 index 00000000000..ca64d1aada0 --- /dev/null +++ b/spec/factories/ci/pipeline_schedule_variables.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do + sequence(:key) { |n| "VARIABLE_#{n}" } + value 'VARIABLE_VALUE' + + pipeline_schedule factory: :ci_pipeline_schedule + end +end diff --git a/spec/factories/ci/pipeline_variable_variables.rb b/spec/factories/ci/pipeline_variable_variables.rb new file mode 100644 index 00000000000..7c1a7faec08 --- /dev/null +++ b/spec/factories/ci/pipeline_variable_variables.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :ci_pipeline_variable, class: Ci::PipelineVariable do + sequence(:key) { |n| "VARIABLE_#{n}" } + value 'VARIABLE_VALUE' + + pipeline factory: :ci_empty_pipeline + end +end diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 561fbc8e247..e83a0e599a8 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -1,40 +1,47 @@ FactoryGirl.define do factory :ci_empty_pipeline, class: Ci::Pipeline do + source :push ref 'master' sha '97de212e80737a608d939f648d959671fb0a0142' status 'pending' - project factory: :empty_project + project factory :ci_pipeline_without_jobs do after(:build) do |pipeline| - allow(pipeline).to receive(:ci_yaml_file) { YAML.dump({}) } + pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({})) end end factory :ci_pipeline_with_one_job do after(:build) do |pipeline| allow(pipeline).to receive(:ci_yaml_file) do - YAML.dump({ rspec: { script: "ls" } }) + pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({ rspec: { script: "ls" } })) end end end + # 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 + factory :ci_pipeline do transient { config nil } after(:build) do |pipeline, evaluator| - allow(pipeline).to receive(:ci_yaml_file) do - if evaluator.config - YAML.dump(evaluator.config) - else - File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - end - end + if evaluator.config + pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump(evaluator.config)) - # Populates pipeline with errors - # - pipeline.config_processor if evaluator.config + # 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 end trait :invalid do diff --git a/spec/factories/ci/runner_projects.rb b/spec/factories/ci/runner_projects.rb index 6712dd5d82e..fa76d0ecd8c 100644 --- a/spec/factories/ci/runner_projects.rb +++ b/spec/factories/ci/runner_projects.rb @@ -1,6 +1,6 @@ FactoryGirl.define do factory :ci_runner_project, class: Ci::RunnerProject do - runner_id 1 - project_id 1 + runner factory: :ci_runner + project end end diff --git a/spec/factories/ci/stages.rb b/spec/factories/ci/stages.rb index 7f557b25ccb..d3c8bf9d54f 100644 --- a/spec/factories/ci/stages.rb +++ b/spec/factories/ci/stages.rb @@ -1,5 +1,7 @@ FactoryGirl.define do - factory :ci_stage, class: Ci::Stage do + factory :ci_stage, class: Ci::LegacyStage do + skip_create + transient do name 'test' status nil @@ -8,7 +10,9 @@ FactoryGirl.define do end initialize_with do - Ci::Stage.new(pipeline, name: name, status: status, warnings: warnings) + Ci::LegacyStage.new(pipeline, name: name, + status: status, + warnings: warnings) end end end diff --git a/spec/factories/ci/trigger_requests.rb b/spec/factories/ci/trigger_requests.rb index b8d8fab0e0b..10e0ab4fd3c 100644 --- a/spec/factories/ci/trigger_requests.rb +++ b/spec/factories/ci/trigger_requests.rb @@ -1,8 +1,8 @@ FactoryGirl.define do factory :ci_trigger_request, class: Ci::TriggerRequest do - factory :ci_trigger_request_with_variables do - trigger factory: :ci_trigger + trigger factory: :ci_trigger + factory :ci_trigger_request_with_variables do variables do { TRIGGER_KEY_1: 'TRIGGER_VALUE_1', diff --git a/spec/factories/ci/triggers.rb b/spec/factories/ci/triggers.rb index c3a29d8bf04..40c4663c6d8 100644 --- a/spec/factories/ci/triggers.rb +++ b/spec/factories/ci/triggers.rb @@ -2,13 +2,6 @@ FactoryGirl.define do factory :ci_trigger_without_token, class: Ci::Trigger do factory :ci_trigger do sequence(:token) { |n| "token#{n}" } - - factory :ci_trigger_for_trigger_schedule do - token { SecureRandom.hex(15) } - owner factory: :user - project factory: :project - ref 'master' - end end end end diff --git a/spec/factories/ci/variables.rb b/spec/factories/ci/variables.rb index 6653f0bb5c3..d8fd513ffcf 100644 --- a/spec/factories/ci/variables.rb +++ b/spec/factories/ci/variables.rb @@ -2,5 +2,11 @@ FactoryGirl.define do factory :ci_variable, class: Ci::Variable do sequence(:key) { |n| "VARIABLE_#{n}" } value 'VARIABLE_VALUE' + + trait(:protected) do + protected true + end + + project end end |