2020-07-08 08:09:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
FactoryBot.define do
|
|
|
|
factory :package, class: 'Packages::Package' do
|
|
|
|
project
|
2020-09-08 11:08:41 -04:00
|
|
|
creator { project&.creator }
|
2020-07-08 08:09:33 -04:00
|
|
|
name { 'my/company/app/my-app' }
|
|
|
|
sequence(:version) { |n| "1.#{n}-SNAPSHOT" }
|
|
|
|
package_type { :maven }
|
2021-02-17 07:09:26 -05:00
|
|
|
status { :default }
|
|
|
|
|
|
|
|
trait :hidden do
|
|
|
|
status { :hidden }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :processing do
|
|
|
|
status { :processing }
|
|
|
|
end
|
2020-07-08 08:09:33 -04:00
|
|
|
|
2021-03-30 08:10:51 -04:00
|
|
|
trait :error do
|
|
|
|
status { :error }
|
|
|
|
end
|
|
|
|
|
2022-02-03 19:13:53 -05:00
|
|
|
trait :pending_destruction do
|
|
|
|
status { :pending_destruction }
|
|
|
|
end
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
factory :maven_package do
|
|
|
|
maven_metadatum
|
|
|
|
|
|
|
|
after :build do |package|
|
2020-08-11 11:10:08 -04:00
|
|
|
package.maven_metadatum.path = package.version? ? "#{package.name}/#{package.version}" : package.name
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
after :create do |package|
|
|
|
|
create :package_file, :xml, package: package
|
|
|
|
create :package_file, :jar, package: package
|
|
|
|
create :package_file, :pom, package: package
|
|
|
|
end
|
2021-02-09 19:09:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :rubygems_package do
|
|
|
|
sequence(:name) { |n| "my_gem_#{n}" }
|
|
|
|
sequence(:version) { |n| "1.#{n}" }
|
|
|
|
package_type { :rubygems }
|
|
|
|
|
|
|
|
after :create do |package|
|
2021-03-26 11:09:18 -04:00
|
|
|
create :package_file, package.processing? ? :unprocessed_gem : :gem, package: package
|
|
|
|
create :package_file, :gemspec, package: package unless package.processing?
|
2021-02-09 19:09:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
trait(:with_metadatum) do
|
|
|
|
after :build do |pkg|
|
|
|
|
pkg.rubygems_metadatum = build(:rubygems_metadatum)
|
|
|
|
end
|
|
|
|
end
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|
|
|
|
|
2020-10-05 08:08:47 -04:00
|
|
|
factory :debian_package do
|
2020-12-11 16:10:13 -05:00
|
|
|
sequence(:name) { |n| "package-#{n}" }
|
|
|
|
sequence(:version) { |n| "1.0-#{n}" }
|
2020-10-05 08:08:47 -04:00
|
|
|
package_type { :debian }
|
2020-12-11 16:10:13 -05:00
|
|
|
|
2020-12-21 01:10:03 -05:00
|
|
|
transient do
|
|
|
|
without_package_files { false }
|
|
|
|
file_metadatum_trait { :keep }
|
2021-02-08 04:09:30 -05:00
|
|
|
published_in { :create }
|
|
|
|
end
|
|
|
|
|
|
|
|
after :build do |package, evaluator|
|
|
|
|
if evaluator.published_in == :create
|
|
|
|
create(:debian_publication, package: package)
|
|
|
|
elsif !evaluator.published_in.nil?
|
|
|
|
create(:debian_publication, package: package, distribution: evaluator.published_in)
|
|
|
|
end
|
2020-12-21 01:10:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
after :create do |package, evaluator|
|
|
|
|
unless evaluator.without_package_files
|
|
|
|
create :debian_package_file, :source, evaluator.file_metadatum_trait, package: package
|
|
|
|
create :debian_package_file, :dsc, evaluator.file_metadatum_trait, package: package
|
|
|
|
create :debian_package_file, :deb, evaluator.file_metadatum_trait, package: package
|
2021-05-24 05:10:31 -04:00
|
|
|
create :debian_package_file, :deb_dev, evaluator.file_metadatum_trait, package: package
|
2020-12-21 01:10:03 -05:00
|
|
|
create :debian_package_file, :udeb, evaluator.file_metadatum_trait, package: package
|
|
|
|
create :debian_package_file, :buildinfo, evaluator.file_metadatum_trait, package: package
|
|
|
|
create :debian_package_file, :changes, evaluator.file_metadatum_trait, package: package
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-12-11 16:10:13 -05:00
|
|
|
factory :debian_incoming do
|
|
|
|
name { 'incoming' }
|
|
|
|
version { nil }
|
2020-12-21 01:10:03 -05:00
|
|
|
|
|
|
|
transient do
|
|
|
|
without_package_files { false }
|
|
|
|
file_metadatum_trait { :unknown }
|
2021-02-08 04:09:30 -05:00
|
|
|
published_in { nil }
|
2020-12-21 01:10:03 -05:00
|
|
|
end
|
2020-12-11 16:10:13 -05:00
|
|
|
end
|
2020-10-05 08:08:47 -04:00
|
|
|
end
|
|
|
|
|
2021-05-04 14:10:03 -04:00
|
|
|
factory :helm_package do
|
|
|
|
sequence(:name) { |n| "package-#{n}" }
|
|
|
|
sequence(:version) { |n| "v1.0.#{n}" }
|
|
|
|
package_type { :helm }
|
|
|
|
|
|
|
|
transient do
|
|
|
|
without_package_files { false }
|
|
|
|
end
|
|
|
|
|
|
|
|
after :create do |package, evaluator|
|
|
|
|
unless evaluator.without_package_files
|
|
|
|
create :helm_package_file, package: package
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
factory :npm_package do
|
|
|
|
sequence(:name) { |n| "@#{project.root_namespace.path}/package-#{n}"}
|
2021-08-23 14:11:07 -04:00
|
|
|
sequence(:version) { |n| "1.0.#{n}" }
|
2020-07-08 08:09:33 -04:00
|
|
|
package_type { :npm }
|
|
|
|
|
|
|
|
after :create do |package|
|
|
|
|
create :package_file, :npm, package: package
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_build do
|
|
|
|
after :create do |package|
|
|
|
|
user = package.project.creator
|
|
|
|
pipeline = create(:ci_pipeline, user: user)
|
|
|
|
create(:ci_build, user: user, pipeline: pipeline)
|
|
|
|
create :package_build_info, package: package, pipeline: pipeline
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-13 20:11:05 -04:00
|
|
|
factory :terraform_module_package do
|
|
|
|
sequence(:name) { |n| "module-#{n}/system" }
|
|
|
|
version { '1.0.0' }
|
|
|
|
package_type { :terraform_module }
|
|
|
|
|
|
|
|
after :create do |package|
|
|
|
|
create :package_file, :terraform_module, package: package
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_build do
|
|
|
|
after :create do |package|
|
|
|
|
user = package.project.creator
|
|
|
|
pipeline = create(:ci_pipeline, user: user)
|
|
|
|
create(:ci_build, user: user, pipeline: pipeline)
|
|
|
|
create :package_build_info, package: package, pipeline: pipeline
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
factory :nuget_package do
|
|
|
|
sequence(:name) { |n| "NugetPackage#{n}"}
|
|
|
|
sequence(:version) { |n| "1.0.#{n}" }
|
|
|
|
package_type { :nuget }
|
|
|
|
|
|
|
|
after :create do |package|
|
|
|
|
create :package_file, :nuget, package: package, file_name: "#{package.name}.#{package.version}.nupkg"
|
|
|
|
end
|
|
|
|
|
|
|
|
trait(:with_metadatum) do
|
|
|
|
after :build do |pkg|
|
|
|
|
pkg.nuget_metadatum = build(:nuget_metadatum)
|
|
|
|
end
|
|
|
|
end
|
2021-06-18 14:10:13 -04:00
|
|
|
|
|
|
|
trait(:with_symbol_package) do
|
|
|
|
after :create do |package|
|
|
|
|
create :package_file, :snupkg, package: package, file_name: "#{package.name}.#{package.version}.snupkg"
|
|
|
|
end
|
|
|
|
end
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :pypi_package do
|
|
|
|
sequence(:name) { |n| "pypi-package-#{n}"}
|
|
|
|
sequence(:version) { |n| "1.0.#{n}" }
|
|
|
|
package_type { :pypi }
|
|
|
|
|
2020-08-24 17:10:17 -04:00
|
|
|
transient do
|
|
|
|
without_loaded_metadatum { false }
|
|
|
|
end
|
|
|
|
|
|
|
|
after :create do |package, evaluator|
|
2020-07-08 08:09:33 -04:00
|
|
|
create :package_file, :pypi, package: package, file_name: "#{package.name}-#{package.version}.tar.gz"
|
2020-08-24 17:10:17 -04:00
|
|
|
|
|
|
|
unless evaluator.without_loaded_metadatum
|
|
|
|
create :pypi_metadatum, package: package
|
|
|
|
end
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :composer_package do
|
|
|
|
sequence(:name) { |n| "composer-package-#{n}"}
|
|
|
|
sequence(:version) { |n| "1.0.#{n}" }
|
|
|
|
package_type { :composer }
|
|
|
|
|
|
|
|
transient do
|
|
|
|
sha { project.repository.find_branch('master').target }
|
|
|
|
json { { name: name, version: version } }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait(:with_metadatum) do
|
|
|
|
after :create do |package, evaluator|
|
|
|
|
create :composer_metadatum, package: package, target_sha: evaluator.sha, composer_json: evaluator.json
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-22 11:09:37 -04:00
|
|
|
factory :golang_package do
|
|
|
|
sequence(:name) { |n| "golang.org/x/pkg-#{n}"}
|
|
|
|
sequence(:version) { |n| "v1.0.#{n}" }
|
|
|
|
package_type { :golang }
|
|
|
|
end
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
factory :conan_package do
|
|
|
|
conan_metadatum
|
|
|
|
|
|
|
|
transient do
|
|
|
|
without_package_files { false }
|
|
|
|
end
|
|
|
|
|
|
|
|
after :build do |package|
|
|
|
|
package.conan_metadatum.package_username = Packages::Conan::Metadatum.package_username_from(
|
|
|
|
full_path: package.project.full_path
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
sequence(:name) { |n| "package-#{n}" }
|
|
|
|
version { '1.0.0' }
|
|
|
|
package_type { :conan }
|
|
|
|
|
|
|
|
after :create do |package, evaluator|
|
|
|
|
unless evaluator.without_package_files
|
|
|
|
create :conan_package_file, :conan_recipe_file, package: package
|
|
|
|
create :conan_package_file, :conan_recipe_manifest, package: package
|
|
|
|
create :conan_package_file, :conan_package_info, package: package
|
|
|
|
create :conan_package_file, :conan_package_manifest, package: package
|
|
|
|
create :conan_package_file, :conan_package, package: package
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait(:without_loaded_metadatum) do
|
2020-11-16 07:09:05 -05:00
|
|
|
conan_metadatum { build(:conan_metadatum, package: nil) } # rubocop:disable FactoryBot/InlineAssociation
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|
|
|
|
end
|
2020-09-01 17:10:21 -04:00
|
|
|
|
|
|
|
factory :generic_package do
|
|
|
|
sequence(:name) { |n| "generic-package-#{n}" }
|
|
|
|
version { '1.0.0' }
|
|
|
|
package_type { :generic }
|
2021-12-15 19:15:50 -05:00
|
|
|
|
|
|
|
trait(:with_zip_file) do
|
|
|
|
after :create do |package|
|
|
|
|
create :package_file, :generic_zip, package: package
|
|
|
|
end
|
|
|
|
end
|
2020-09-01 17:10:21 -04:00
|
|
|
end
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|
|
|
|
end
|