Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/factories/ci')
-rw-r--r--spec/factories/ci/builds.rb23
-rw-r--r--spec/factories/ci/daily_build_group_report_results.rb8
-rw-r--r--spec/factories/ci/job_artifacts.rb20
-rw-r--r--spec/factories/ci/pipelines.rb8
-rw-r--r--spec/factories/ci/reports/test_case.rb41
-rw-r--r--spec/factories/ci/test_case.rb39
-rw-r--r--spec/factories/ci/test_case_failure.rb9
7 files changed, 111 insertions, 37 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 73920b76025..11719e40cf2 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -332,6 +332,18 @@ FactoryBot.define do
end
end
+ trait :test_reports_with_duplicate_failed_test_names do
+ after(:build) do |build|
+ build.job_artifacts << create(:ci_job_artifact, :junit_with_duplicate_failed_test_names, job: build)
+ end
+ end
+
+ trait :test_reports_with_three_failures do
+ after(:build) do |build|
+ build.job_artifacts << create(:ci_job_artifact, :junit_with_three_failures, job: build)
+ end
+ end
+
trait :accessibility_reports do
after(:build) do |build|
build.job_artifacts << create(:ci_job_artifact, :accessibility, job: build)
@@ -492,10 +504,21 @@ FactoryBot.define do
failure_reason { 10 }
end
+ trait :forward_deployment_failure do
+ failed
+ failure_reason { 13 }
+ end
+
trait :with_runner_session do
after(:build) do |build|
build.build_runner_session(url: 'https://localhost')
end
end
+
+ trait :interruptible do
+ after(:build) do |build|
+ build.metadata.interruptible = true
+ end
+ end
end
end
diff --git a/spec/factories/ci/daily_build_group_report_results.rb b/spec/factories/ci/daily_build_group_report_results.rb
index 8653316b51a..d836ee9567c 100644
--- a/spec/factories/ci/daily_build_group_report_results.rb
+++ b/spec/factories/ci/daily_build_group_report_results.rb
@@ -3,12 +3,18 @@
FactoryBot.define do
factory :ci_daily_build_group_report_result, class: 'Ci::DailyBuildGroupReportResult' do
ref_path { Gitlab::Git::BRANCH_REF_PREFIX + 'master' }
- date { Time.zone.now.to_date }
+ date { Date.current }
project
last_pipeline factory: :ci_pipeline
group_name { 'rspec' }
data do
{ 'coverage' => 77.0 }
end
+ default_branch { true }
+
+ trait :on_feature_branch do
+ ref_path { Gitlab::Git::BRANCH_REF_PREFIX + 'feature' }
+ default_branch { false }
+ end
end
end
diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb
index 1bd4b2826c4..223184891b7 100644
--- a/spec/factories/ci/job_artifacts.rb
+++ b/spec/factories/ci/job_artifacts.rb
@@ -109,6 +109,16 @@ FactoryBot.define do
end
end
+ trait :junit_with_duplicate_failed_test_names do
+ file_type { :junit }
+ file_format { :gzip }
+
+ after(:build) do |artifact, evaluator|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/junit/junit_with_duplicate_failed_test_names.xml.gz'), 'application/x-gzip')
+ end
+ end
+
trait :junit_with_ant do
file_type { :junit }
file_format { :gzip }
@@ -139,6 +149,16 @@ FactoryBot.define do
end
end
+ trait :junit_with_three_failures do
+ file_type { :junit }
+ file_format { :gzip }
+
+ after(:build) do |artifact, evaluator|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/junit/junit_with_three_failures.xml.gz'), 'application/x-gzip')
+ end
+ end
+
trait :accessibility do
file_type { :accessibility }
file_format { :raw }
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index 4fa5dde4eff..14bd0ab1bc6 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -121,6 +121,14 @@ FactoryBot.define do
end
end
+ trait :with_test_reports_with_three_failures do
+ status { :success }
+
+ after(:build) do |pipeline, _evaluator|
+ pipeline.builds << build(:ci_build, :test_reports_with_three_failures, pipeline: pipeline, project: pipeline.project)
+ end
+ end
+
trait :with_accessibility_reports do
status { :success }
diff --git a/spec/factories/ci/reports/test_case.rb b/spec/factories/ci/reports/test_case.rb
new file mode 100644
index 00000000000..0626de9d6dc
--- /dev/null
+++ b/spec/factories/ci/reports/test_case.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :report_test_case, class: 'Gitlab::Ci::Reports::TestCase' do
+ suite_name { "rspec" }
+ name { "test-1" }
+ classname { "trace" }
+ file { "spec/trace_spec.rb" }
+ execution_time { 1.23 }
+ status { Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS }
+ system_output { nil }
+ attachment { nil }
+ association :job, factory: :ci_build
+
+ trait :failed do
+ status { Gitlab::Ci::Reports::TestCase::STATUS_FAILED }
+ system_output { "Failure/Error: is_expected.to eq(300) expected: 300 got: -100" }
+ end
+
+ trait :failed_with_attachment do
+ status { Gitlab::Ci::Reports::TestCase::STATUS_FAILED }
+ attachment { "some/path.png" }
+ end
+
+ skip_create
+
+ initialize_with do
+ new(
+ suite_name: suite_name,
+ name: name,
+ classname: classname,
+ file: file,
+ execution_time: execution_time,
+ status: status,
+ system_output: system_output,
+ attachment: attachment,
+ job: job
+ )
+ end
+ end
+end
diff --git a/spec/factories/ci/test_case.rb b/spec/factories/ci/test_case.rb
index 7f99f0e123e..601a3fae970 100644
--- a/spec/factories/ci/test_case.rb
+++ b/spec/factories/ci/test_case.rb
@@ -1,41 +1,8 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :test_case, class: 'Gitlab::Ci::Reports::TestCase' do
- suite_name { "rspec" }
- name { "test-1" }
- classname { "trace" }
- file { "spec/trace_spec.rb" }
- execution_time { 1.23 }
- status { Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS }
- system_output { nil }
- attachment { nil }
- association :job, factory: :ci_build
-
- trait :failed do
- status { Gitlab::Ci::Reports::TestCase::STATUS_FAILED }
- system_output { "Failure/Error: is_expected.to eq(300) expected: 300 got: -100" }
- end
-
- trait :failed_with_attachment do
- status { Gitlab::Ci::Reports::TestCase::STATUS_FAILED }
- attachment { "some/path.png" }
- end
-
- skip_create
-
- initialize_with do
- new(
- suite_name: suite_name,
- name: name,
- classname: classname,
- file: file,
- execution_time: execution_time,
- status: status,
- system_output: system_output,
- attachment: attachment,
- job: job
- )
- end
+ factory :ci_test_case, class: 'Ci::TestCase' do
+ project
+ key_hash { Digest::SHA256.hexdigest(SecureRandom.hex) }
end
end
diff --git a/spec/factories/ci/test_case_failure.rb b/spec/factories/ci/test_case_failure.rb
new file mode 100644
index 00000000000..11fb002804b
--- /dev/null
+++ b/spec/factories/ci/test_case_failure.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :ci_test_case_failure, class: 'Ci::TestCaseFailure' do
+ build factory: :ci_build
+ test_case factory: :ci_test_case
+ failed_at { Time.current }
+ end
+end