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

84 lines
2.3 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
FactoryBot.define do
factory :ci_pipeline_artifact, class: 'Ci::PipelineArtifact' do
pipeline factory: :ci_pipeline
project { pipeline.project }
file_format { :raw }
2020-11-24 15:15:51 +05:30
file_store { ObjectStorage::SUPPORTED_STORES.first }
2021-03-11 19:13:27 +05:30
size { 1.megabyte }
file_type { :code_coverage }
2020-10-24 23:57:45 +05:30
after(:build) do |artifact, _evaluator|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage.json'), 'application/json')
end
2020-11-24 15:15:51 +05:30
2021-06-08 01:23:25 +05:30
trait :unlocked do
association :pipeline, :unlocked, factory: :ci_pipeline
end
2021-04-29 21:17:54 +05:30
trait :checksummed do
verification_checksum { 'abc' }
end
trait :checksum_failure do
verification_failure { 'Could not calculate the checksum' }
end
trait :expired do
expire_at { Date.yesterday }
end
trait :remote_store do
file_store { ::ObjectStorage::Store::REMOTE}
end
2021-03-11 19:13:27 +05:30
trait :with_coverage_report do
file_type { :code_coverage }
after(:build) do |artifact, _evaluator|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage.json'), 'application/json')
end
size { file.size }
end
trait :with_coverage_multibyte_characters do
file_type { :code_coverage }
2020-11-24 15:15:51 +05:30
size { { "utf8" => "" }.to_json.bytesize }
2021-03-11 19:13:27 +05:30
2020-11-24 15:15:51 +05:30
after(:build) do |artifact, _evaluator|
artifact.file = CarrierWaveStringFile.new_file(
file_content: { "utf8" => "" }.to_json,
filename: 'filename',
content_type: 'application/json'
)
end
end
trait :with_code_coverage_with_multiple_files do
2021-03-11 19:13:27 +05:30
file_type { :code_coverage }
2020-11-24 15:15:51 +05:30
after(:build) do |artifact, _evaluator|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage_with_multiple_files.json'), 'application/json'
)
end
2021-03-11 19:13:27 +05:30
size { 1.megabyte }
end
trait :with_codequality_mr_diff_report do
file_type { :code_quality_mr_diff }
after(:build) do |artifact, _evaluator|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/pipeline_artifacts/code_quality_mr_diff.json'), 'application/json')
end
2020-11-24 15:15:51 +05:30
size { file.size }
end
2020-10-24 23:57:45 +05:30
end
end