diff options
Diffstat (limited to 'spec/factories/ci')
-rw-r--r-- | spec/factories/ci/bridge.rb | 13 | ||||
-rw-r--r-- | spec/factories/ci/build_pending_states.rb | 2 | ||||
-rw-r--r-- | spec/factories/ci/build_trace_chunks.rb | 13 | ||||
-rw-r--r-- | spec/factories/ci/builds.rb | 3 | ||||
-rw-r--r-- | spec/factories/ci/deleted_object.rb | 9 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 18 | ||||
-rw-r--r-- | spec/factories/ci/test_case.rb | 2 |
7 files changed, 57 insertions, 3 deletions
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb index 5a33a30921b..7727a468633 100644 --- a/spec/factories/ci/bridge.rb +++ b/spec/factories/ci/bridge.rb @@ -40,6 +40,10 @@ FactoryBot.define do end end + trait :created do + status { 'created' } + end + trait :started do started_at { '2013-10-29 09:51:28 CET' } end @@ -62,5 +66,14 @@ FactoryBot.define do trait :strategy_depend do options { { trigger: { strategy: 'depend' } } } end + + trait :manual do + status { 'manual' } + self.when { 'manual' } + end + + trait :playable do + manual + end end end diff --git a/spec/factories/ci/build_pending_states.rb b/spec/factories/ci/build_pending_states.rb index 765b7f005b9..eddd74b1068 100644 --- a/spec/factories/ci/build_pending_states.rb +++ b/spec/factories/ci/build_pending_states.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :ci_build_pending_state, class: 'Ci::BuildPendingState' do build factory: :ci_build - trace_checksum { 'crc32:12345678' } + trace_checksum { 'crc32:bc614e' } state { 'success' } end end diff --git a/spec/factories/ci/build_trace_chunks.rb b/spec/factories/ci/build_trace_chunks.rb index 7c348f4b7e4..d996b41b648 100644 --- a/spec/factories/ci/build_trace_chunks.rb +++ b/spec/factories/ci/build_trace_chunks.rb @@ -53,5 +53,18 @@ FactoryBot.define do trait :fog_without_data do data_store { :fog } end + + trait :persisted do + data_store { :database} + + transient do + initial_data { 'test data' } + end + + after(:build) do |chunk, evaluator| + Ci::BuildTraceChunks::Database.new.set_data(chunk, evaluator.initial_data) + chunk.checksum = chunk.class.crc32(evaluator.initial_data) + end + end end end diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index b3815b53c2b..73920b76025 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -384,7 +384,8 @@ FactoryBot.define do key: 'cache_key', untracked: false, paths: ['vendor/*'], - policy: 'pull-push' + policy: 'pull-push', + when: 'on_success' } } end diff --git a/spec/factories/ci/deleted_object.rb b/spec/factories/ci/deleted_object.rb new file mode 100644 index 00000000000..c91d259ffeb --- /dev/null +++ b/spec/factories/ci/deleted_object.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_deleted_object, class: 'Ci::DeletedObject' do + pick_up_at { Time.current } + store_dir { SecureRandom.uuid } + file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip') } + end +end diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 6174bfbfbb7..4fa5dde4eff 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -15,15 +15,31 @@ FactoryBot.define do # on pipeline factories to avoid circular references transient { head_pipeline_of { nil } } + transient { child_of { nil } } + + after(:build) do |pipeline, evaluator| + if evaluator.child_of + pipeline.project = evaluator.child_of.project + pipeline.source = :parent_pipeline + end + end + after(:create) do |pipeline, evaluator| merge_request = evaluator.head_pipeline_of merge_request&.update!(head_pipeline: pipeline) + + if evaluator.child_of + bridge = create(:ci_bridge, pipeline: evaluator.child_of) + create(:ci_sources_pipeline, + source_job: bridge, + pipeline: pipeline) + end end factory :ci_pipeline do transient { ci_ref_presence { true } } - after(:build) do |pipeline, evaluator| + before(:create) do |pipeline, evaluator| pipeline.ensure_ci_ref! if evaluator.ci_ref_presence && pipeline.ci_ref_id.nil? end diff --git a/spec/factories/ci/test_case.rb b/spec/factories/ci/test_case.rb index 0639aac566a..7f99f0e123e 100644 --- a/spec/factories/ci/test_case.rb +++ b/spec/factories/ci/test_case.rb @@ -2,6 +2,7 @@ FactoryBot.define do factory :test_case, class: 'Gitlab::Ci::Reports::TestCase' do + suite_name { "rspec" } name { "test-1" } classname { "trace" } file { "spec/trace_spec.rb" } @@ -25,6 +26,7 @@ FactoryBot.define do initialize_with do new( + suite_name: suite_name, name: name, classname: classname, file: file, |