summaryrefslogtreecommitdiff
path: root/spec/factories/packages.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 10:34:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 10:34:06 +0000
commit859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch)
treed7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/factories/packages.rb
parent446d496a6d000c73a304be52587cd9bbc7493136 (diff)
downloadgitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/factories/packages.rb')
-rw-r--r--spec/factories/packages.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb
index 31f1aabe5dd..2c64abefb01 100644
--- a/spec/factories/packages.rb
+++ b/spec/factories/packages.rb
@@ -6,6 +6,15 @@ FactoryBot.define do
name { 'my/company/app/my-app' }
sequence(:version) { |n| "1.#{n}-SNAPSHOT" }
package_type { :maven }
+ status { :default }
+
+ trait :hidden do
+ status { :hidden }
+ end
+
+ trait :processing do
+ status { :processing }
+ end
factory :maven_package do
maven_metadatum
@@ -21,6 +30,23 @@ FactoryBot.define do
end
end
+ factory :rubygems_package do
+ sequence(:name) { |n| "my_gem_#{n}" }
+ sequence(:version) { |n| "1.#{n}" }
+ package_type { :rubygems }
+
+ after :create do |package|
+ create :package_file, :gem, package: package
+ create :package_file, :gemspec, package: package
+ end
+
+ trait(:with_metadatum) do
+ after :build do |pkg|
+ pkg.rubygems_metadatum = build(:rubygems_metadatum)
+ end
+ end
+ end
+
factory :debian_package do
sequence(:name) { |n| "package-#{n}" }
sequence(:version) { |n| "1.0-#{n}" }
@@ -29,6 +55,15 @@ FactoryBot.define do
transient do
without_package_files { false }
file_metadatum_trait { :keep }
+ 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
end
after :create do |package, evaluator|
@@ -50,6 +85,7 @@ FactoryBot.define do
transient do
without_package_files { false }
file_metadatum_trait { :unknown }
+ published_in { nil }
end
end
end
@@ -176,6 +212,24 @@ FactoryBot.define do
composer_json { { name: 'foo' } }
end
+ factory :composer_cache_file, class: 'Packages::Composer::CacheFile' do
+ group
+
+ file_sha256 { '1' * 64 }
+
+ transient do
+ file_fixture { 'spec/fixtures/packages/composer/package.json' }
+ end
+
+ after(:build) do |cache_file, evaluator|
+ cache_file.file = fixture_file_upload(evaluator.file_fixture)
+ end
+
+ trait(:object_storage) do
+ file_store { Packages::Composer::CacheUploader::Store::REMOTE }
+ end
+ end
+
factory :maven_metadatum, class: 'Packages::Maven::Metadatum' do
association :package, package_type: :maven
path { 'my/company/app/my-app/1.0-SNAPSHOT' }