summaryrefslogtreecommitdiff
path: root/spec/factories/ci
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/factories/ci
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
downloadgitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/factories/ci')
-rw-r--r--spec/factories/ci/builds.rb15
-rw-r--r--spec/factories/ci/pipeline_artifacts.rb16
-rw-r--r--spec/factories/ci/reports/codequality_degradations.rb43
-rw-r--r--spec/factories/ci/unit_test.rb (renamed from spec/factories/ci/test_case.rb)4
-rw-r--r--spec/factories/ci/unit_test_failure.rb (renamed from spec/factories/ci/test_case_failure.rb)4
5 files changed, 79 insertions, 3 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 886be520668..b06d581d2c0 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -30,6 +30,21 @@ FactoryBot.define do
yaml_variables { nil }
end
+ trait :unique_name do
+ name { generate(:job_name) }
+ end
+
+ trait :dependent do
+ transient do
+ sequence(:needed_name) { |n| "dependency #{n}" }
+ needed { association(:ci_build, name: needed_name, pipeline: pipeline) }
+ end
+
+ after(:create) do |build, evaluator|
+ build.needs << create(:ci_build_need, build: build, name: evaluator.needed.name)
+ end
+ end
+
trait :started do
started_at { 'Di 29. Okt 09:51:28 CET 2013' }
end
diff --git a/spec/factories/ci/pipeline_artifacts.rb b/spec/factories/ci/pipeline_artifacts.rb
index 05ff7afed7c..3250c7abb4b 100644
--- a/spec/factories/ci/pipeline_artifacts.rb
+++ b/spec/factories/ci/pipeline_artifacts.rb
@@ -13,6 +13,22 @@ FactoryBot.define do
Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage.json'), 'application/json')
end
+ 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
+
trait :with_coverage_report do
file_type { :code_coverage }
diff --git a/spec/factories/ci/reports/codequality_degradations.rb b/spec/factories/ci/reports/codequality_degradations.rb
index d82157b457a..8b53f2bf46e 100644
--- a/spec/factories/ci/reports/codequality_degradations.rb
+++ b/spec/factories/ci/reports/codequality_degradations.rb
@@ -95,4 +95,47 @@ FactoryBot.define do
}.with_indifferent_access
end
end
+
+ # TODO: Use this in all other specs and remove the previous numbered factories
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/325886
+ factory :codequality_degradation, class: Hash do
+ skip_create
+
+ # Feel free to add in more configurable properties here
+ # as the need arises
+ fingerprint { SecureRandom.hex }
+ severity { "major" }
+
+ Gitlab::Ci::Reports::CodequalityReports::SEVERITY_PRIORITIES.keys.each do |s|
+ trait s.to_sym do
+ severity { s }
+ end
+ end
+
+ initialize_with do
+ {
+ "categories": [
+ "Complexity"
+ ],
+ "check_name": "argument_count",
+ "content": {
+ "body": ""
+ },
+ "description": "Avoid parameter lists longer than 5 parameters. [12/5]",
+ "fingerprint": fingerprint,
+ "location": {
+ "path": "file_a.rb",
+ "lines": {
+ "begin": 10,
+ "end": 10
+ }
+ },
+ "other_locations": [],
+ "remediation_points": 900000,
+ "severity": severity,
+ "type": "issue",
+ "engine_name": "structure"
+ }.with_indifferent_access
+ end
+ end
end
diff --git a/spec/factories/ci/test_case.rb b/spec/factories/ci/unit_test.rb
index 601a3fae970..480724f260a 100644
--- a/spec/factories/ci/test_case.rb
+++ b/spec/factories/ci/unit_test.rb
@@ -1,8 +1,10 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :ci_test_case, class: 'Ci::TestCase' do
+ factory :ci_unit_test, class: 'Ci::UnitTest' do
project
+ suite_name { 'rspec' }
+ name { 'Math#add returns sum' }
key_hash { Digest::SHA256.hexdigest(SecureRandom.hex) }
end
end
diff --git a/spec/factories/ci/test_case_failure.rb b/spec/factories/ci/unit_test_failure.rb
index 11fb002804b..07cd3419754 100644
--- a/spec/factories/ci/test_case_failure.rb
+++ b/spec/factories/ci/unit_test_failure.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :ci_test_case_failure, class: 'Ci::TestCaseFailure' do
+ factory :ci_unit_test_failure, class: 'Ci::UnitTestFailure' do
build factory: :ci_build
- test_case factory: :ci_test_case
+ unit_test factory: :ci_unit_test
failed_at { Time.current }
end
end