diff options
Diffstat (limited to 'spec/factories/ci')
-rw-r--r-- | spec/factories/ci/builds.rb | 6 | ||||
-rw-r--r-- | spec/factories/ci/job_artifacts.rb | 22 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 22 |
3 files changed, 44 insertions, 6 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 11719e40cf2..c3d6e9d7569 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -356,6 +356,12 @@ FactoryBot.define do end end + trait :codequality_reports do + after(:build) do |build| + build.job_artifacts << create(:ci_job_artifact, :codequality, job: build) + end + end + trait :terraform_reports do after(:build) do |build| build.job_artifacts << create(:ci_job_artifact, :terraform, job: build) diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb index 223184891b7..ad98e9d1f24 100644 --- a/spec/factories/ci/job_artifacts.rb +++ b/spec/factories/ci/job_artifacts.rb @@ -229,6 +229,16 @@ FactoryBot.define do end end + trait :coverage_with_paths_not_relative_to_project_root do + file_type { :cobertura } + file_format { :gzip } + + after(:build) do |artifact, evaluator| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/cobertura/coverage_with_paths_not_relative_to_project_root.xml.gz'), 'application/x-gzip') + end + end + trait :coverage_with_corrupted_data do file_type { :cobertura } file_format { :gzip } @@ -245,7 +255,17 @@ FactoryBot.define do after(:build) do |artifact, evaluator| artifact.file = fixture_file_upload( - Rails.root.join('spec/fixtures/codequality/codequality.json'), 'application/json') + Rails.root.join('spec/fixtures/codequality/codeclimate.json'), 'application/json') + end + end + + trait :codequality_without_errors do + file_type { :codequality } + file_format { :raw } + + after(:build) do |artifact, evaluator| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/codequality/codeclimate_without_errors.json'), 'application/json') end end diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 14bd0ab1bc6..86a8b008e48 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -16,6 +16,7 @@ FactoryBot.define do transient { head_pipeline_of { nil } } transient { child_of { nil } } + transient { upstream_of { nil } } after(:build) do |pipeline, evaluator| if evaluator.child_of @@ -30,9 +31,12 @@ FactoryBot.define do if evaluator.child_of bridge = create(:ci_bridge, pipeline: evaluator.child_of) - create(:ci_sources_pipeline, - source_job: bridge, - pipeline: pipeline) + create(:ci_sources_pipeline, source_job: bridge, pipeline: pipeline) + end + + if evaluator.upstream_of + bridge = create(:ci_bridge, pipeline: pipeline) + create(:ci_sources_pipeline, source_job: bridge, pipeline: evaluator.upstream_of) end end @@ -122,10 +126,10 @@ FactoryBot.define do end trait :with_test_reports_with_three_failures do - status { :success } + status { :failed } after(:build) do |pipeline, _evaluator| - pipeline.builds << build(:ci_build, :test_reports_with_three_failures, pipeline: pipeline, project: pipeline.project) + pipeline.builds << build(:ci_build, :failed, :test_reports_with_three_failures, pipeline: pipeline, project: pipeline.project) end end @@ -145,6 +149,14 @@ FactoryBot.define do end end + trait :with_codequality_reports do + status { :success } + + after(:build) do |pipeline, evaluator| + pipeline.builds << build(:ci_build, :codequality_reports, pipeline: pipeline, project: pipeline.project) + end + end + trait :with_coverage_report_artifact do after(:build) do |pipeline, evaluator| pipeline.pipeline_artifacts << build(:ci_pipeline_artifact, pipeline: pipeline, project: pipeline.project) |