diff options
Diffstat (limited to 'spec/factories/ci')
-rw-r--r-- | spec/factories/ci/builds.rb | 18 | ||||
-rw-r--r-- | spec/factories/ci/daily_build_group_report_results.rb (renamed from spec/factories/ci/daily_report_results.rb) | 9 | ||||
-rw-r--r-- | spec/factories/ci/freeze_periods.rb | 10 | ||||
-rw-r--r-- | spec/factories/ci/instance_variables.rb | 13 | ||||
-rw-r--r-- | spec/factories/ci/job_artifacts.rb | 74 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 24 | ||||
-rw-r--r-- | spec/factories/ci/test_case.rb | 2 |
7 files changed, 142 insertions, 8 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index fb3c163dff1..26786aab12c 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -314,12 +314,30 @@ FactoryBot.define do end end + trait :broken_test_reports do + after(:build) do |build| + build.job_artifacts << create(:ci_job_artifact, :junit_with_corrupted_data, job: build) + end + end + + trait :accessibility_reports do + after(:build) do |build| + build.job_artifacts << create(:ci_job_artifact, :accessibility, job: build) + end + end + trait :coverage_reports do after(:build) do |build| build.job_artifacts << create(:ci_job_artifact, :cobertura, job: build) end end + trait :terraform_reports do + after(:build) do |build| + build.job_artifacts << create(:ci_job_artifact, :terraform, job: build) + end + end + trait :expired do artifacts_expire_at { 1.minute.ago } end diff --git a/spec/factories/ci/daily_report_results.rb b/spec/factories/ci/daily_build_group_report_results.rb index e2255e8a134..8653316b51a 100644 --- a/spec/factories/ci/daily_report_results.rb +++ b/spec/factories/ci/daily_build_group_report_results.rb @@ -1,13 +1,14 @@ # frozen_string_literal: true FactoryBot.define do - factory :ci_daily_report_result, class: 'Ci::DailyReportResult' do + factory :ci_daily_build_group_report_result, class: 'Ci::DailyBuildGroupReportResult' do ref_path { Gitlab::Git::BRANCH_REF_PREFIX + 'master' } date { Time.zone.now.to_date } project last_pipeline factory: :ci_pipeline - param_type { Ci::DailyReportResult.param_types[:coverage] } - title { 'rspec' } - value { 77.0 } + group_name { 'rspec' } + data do + { 'coverage' => 77.0 } + end end end diff --git a/spec/factories/ci/freeze_periods.rb b/spec/factories/ci/freeze_periods.rb new file mode 100644 index 00000000000..de48c2076c8 --- /dev/null +++ b/spec/factories/ci/freeze_periods.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_freeze_period, class: 'Ci::FreezePeriod' do + project + freeze_start { '0 23 * * 5' } + freeze_end { '0 7 * * 1' } + cron_timezone { 'UTC' } + end +end diff --git a/spec/factories/ci/instance_variables.rb b/spec/factories/ci/instance_variables.rb new file mode 100644 index 00000000000..5a3551d3561 --- /dev/null +++ b/spec/factories/ci/instance_variables.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_instance_variable, class: 'Ci::InstanceVariable' do + sequence(:key) { |n| "VARIABLE_#{n}" } + value { 'VARIABLE_VALUE' } + masked { false } + + trait(:protected) do + add_attribute(:protected) { true } + end + end +end diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb index 82383cfa2b0..26c09795a0b 100644 --- a/spec/factories/ci/job_artifacts.rb +++ b/spec/factories/ci/job_artifacts.rb @@ -139,6 +139,36 @@ FactoryBot.define do end end + trait :accessibility do + file_type { :accessibility } + file_format { :raw } + + after(:build) do |artifact, _evaluator| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/accessibility/pa11y_with_errors.json'), 'application/json') + end + end + + trait :accessibility_with_invalid_url do + file_type { :accessibility } + file_format { :raw } + + after(:build) do |artifact, _evaluator| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/accessibility/pa11y_with_invalid_url.json'), 'application/json') + end + end + + trait :accessibility_without_errors do + file_type { :accessibility } + file_format { :raw } + + after(:build) do |artifact, _evaluator| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/accessibility/pa11y_without_errors.json'), 'application/json') + end + end + trait :cobertura do file_type { :cobertura } file_format { :gzip } @@ -149,6 +179,26 @@ FactoryBot.define do end end + trait :terraform do + file_type { :terraform } + file_format { :raw } + + after(:build) do |artifact, evaluator| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/terraform/tfplan.json'), 'application/json') + end + end + + trait :terraform_with_corrupted_data do + file_type { :terraform } + file_format { :raw } + + after(:build) do |artifact, evaluator| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/terraform/tfplan_with_corrupted_data.json'), 'application/json') + end + end + trait :coverage_gocov_xml do file_type { :cobertura } file_format { :gzip } @@ -181,11 +231,14 @@ FactoryBot.define do trait :lsif do file_type { :lsif } - file_format { :gzip } + file_format { :zip } + + transient do + file_path { Rails.root.join('spec/fixtures/lsif.json.gz') } + end after(:build) do |artifact, evaluator| - artifact.file = fixture_file_upload( - Rails.root.join('spec/fixtures/lsif.json.gz'), 'application/x-gzip') + artifact.file = fixture_file_upload(evaluator.file_path, 'application/x-gzip') end end @@ -199,6 +252,21 @@ FactoryBot.define do end end + trait :cluster_applications do + file_type { :cluster_applications } + file_format { :gzip } + + transient do + file do + fixture_file_upload(Rails.root.join('spec/fixtures/helm/helm_list_v2_prometheus_missing.json.gz'), 'application/x-gzip') + end + end + + after(:build) do |artifact, evaluator| + artifact.file = evaluator.file + end + end + trait :correct_checksum do after(:build) do |artifact, evaluator| artifact.file_sha256 = Digest::SHA256.file(artifact.file.path).hexdigest diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 257dd3337ba..0b3653a01ed 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -75,6 +75,22 @@ FactoryBot.define do end end + trait :with_broken_test_reports do + status { :success } + + after(:build) do |pipeline, _evaluator| + pipeline.builds << build(:ci_build, :broken_test_reports, pipeline: pipeline, project: pipeline.project) + end + end + + trait :with_accessibility_reports do + status { :success } + + after(:build) do |pipeline, evaluator| + pipeline.builds << build(:ci_build, :accessibility_reports, pipeline: pipeline, project: pipeline.project) + end + end + trait :with_coverage_reports do status { :success } @@ -83,6 +99,14 @@ FactoryBot.define do end end + trait :with_terraform_reports do + status { :success } + + after(:build) do |pipeline, evaluator| + pipeline.builds << build(:ci_build, :terraform_reports, pipeline: pipeline, project: pipeline.project) + end + end + trait :with_exposed_artifacts do status { :success } diff --git a/spec/factories/ci/test_case.rb b/spec/factories/ci/test_case.rb index bb1508c0d75..0639aac566a 100644 --- a/spec/factories/ci/test_case.rb +++ b/spec/factories/ci/test_case.rb @@ -16,7 +16,7 @@ FactoryBot.define do system_output { "Failure/Error: is_expected.to eq(300) expected: 300 got: -100" } end - trait :with_attachment do + trait :failed_with_attachment do status { Gitlab::Ci::Reports::TestCase::STATUS_FAILED } attachment { "some/path.png" } end |