diff options
Diffstat (limited to 'spec/factories/ci/reports/sbom')
-rw-r--r-- | spec/factories/ci/reports/sbom/components.rb | 2 | ||||
-rw-r--r-- | spec/factories/ci/reports/sbom/reports.rb | 18 | ||||
-rw-r--r-- | spec/factories/ci/reports/sbom/sources.rb | 5 |
3 files changed, 20 insertions, 5 deletions
diff --git a/spec/factories/ci/reports/sbom/components.rb b/spec/factories/ci/reports/sbom/components.rb index 317e1c863cf..fd9b4386130 100644 --- a/spec/factories/ci/reports/sbom/components.rb +++ b/spec/factories/ci/reports/sbom/components.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :ci_reports_sbom_component, class: '::Gitlab::Ci::Reports::Sbom::Component' do - type { :library } + type { "library" } sequence(:name) { |n| "component-#{n}" } sequence(:version) { |n| "v0.0.#{n}" } diff --git a/spec/factories/ci/reports/sbom/reports.rb b/spec/factories/ci/reports/sbom/reports.rb new file mode 100644 index 00000000000..4a83b5898ef --- /dev/null +++ b/spec/factories/ci/reports/sbom/reports.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_sbom_report, class: '::Gitlab::Ci::Reports::Sbom::Report' do + transient do + num_components { 5 } + components { build_list :ci_reports_sbom_component, num_components } + source { association :ci_reports_sbom_source } + end + + after(:build) do |report, options| + options.components.each { |component| report.add_component(component) } + report.set_source(options.source) + end + + skip_create + end +end diff --git a/spec/factories/ci/reports/sbom/sources.rb b/spec/factories/ci/reports/sbom/sources.rb index 9093aba86a6..688c0250b5f 100644 --- a/spec/factories/ci/reports/sbom/sources.rb +++ b/spec/factories/ci/reports/sbom/sources.rb @@ -19,15 +19,12 @@ FactoryBot.define do } end - fingerprint { Digest::SHA256.hexdigest(data.to_json) } - skip_create initialize_with do ::Gitlab::Ci::Reports::Sbom::Source.new( type: type, - data: data, - fingerprint: fingerprint + data: data ) end end |