2020-08-07 02:09:47 -04:00
|
|
|
# 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-09-17 17:09:39 -04:00
|
|
|
file_store { ObjectStorage::SUPPORTED_STORES.first }
|
2021-02-01 16:09:15 -05:00
|
|
|
size { 1.megabyte }
|
|
|
|
file_type { :code_coverage }
|
2020-08-12 08:10:25 -04:00
|
|
|
after(:build) do |artifact, _evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage.json'), 'application/json')
|
|
|
|
end
|
2020-08-21 11:10:03 -04:00
|
|
|
|
2021-04-01 14:13:56 -04:00
|
|
|
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-02-01 16:09:15 -05:00
|
|
|
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-08-31 17:10:19 -04:00
|
|
|
size { { "utf8" => "✓" }.to_json.bytesize }
|
2021-02-01 16:09:15 -05:00
|
|
|
|
2020-08-21 11:10:03 -04:00
|
|
|
after(:build) do |artifact, _evaluator|
|
|
|
|
artifact.file = CarrierWaveStringFile.new_file(
|
|
|
|
file_content: { "utf8" => "✓" }.to_json,
|
|
|
|
filename: 'filename',
|
|
|
|
content_type: 'application/json'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2020-08-25 08:04:30 -04:00
|
|
|
|
|
|
|
trait :with_code_coverage_with_multiple_files do
|
2021-02-01 16:09:15 -05:00
|
|
|
file_type { :code_coverage }
|
|
|
|
|
2020-08-25 08:04:30 -04:00
|
|
|
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-02-01 16:09:15 -05:00
|
|
|
size { 1.megabyte }
|
2020-08-25 08:04:30 -04:00
|
|
|
end
|
2021-01-19 16:10:45 -05:00
|
|
|
|
2021-02-03 13:09:25 -05:00
|
|
|
trait :with_codequality_mr_diff_report do
|
|
|
|
file_type { :code_quality_mr_diff }
|
2021-01-19 16:10:45 -05:00
|
|
|
|
|
|
|
after(:build) do |artifact, _evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2021-02-03 13:09:25 -05:00
|
|
|
Rails.root.join('spec/fixtures/pipeline_artifacts/code_quality_mr_diff.json'), 'application/json')
|
2021-01-19 16:10:45 -05:00
|
|
|
end
|
2021-02-01 16:09:15 -05:00
|
|
|
|
|
|
|
size { file.size }
|
2021-01-19 16:10:45 -05:00
|
|
|
end
|
2020-08-07 02:09:47 -04:00
|
|
|
end
|
|
|
|
end
|