summaryrefslogtreecommitdiff
path: root/spec/factories
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
commit983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch)
treeb153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/factories
parenta2bddee2cdb38673df0e004d5b32d9f77797de64 (diff)
downloadgitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/ci/bridge.rb16
-rw-r--r--spec/factories/ci/job_artifacts.rb2
-rw-r--r--spec/factories/clusters/applications/helm.rb9
-rw-r--r--spec/factories/diff_position.rb10
-rw-r--r--spec/factories/import_failures.rb23
-rw-r--r--spec/factories/projects.rb4
-rw-r--r--spec/factories/terraform/state.rb4
-rw-r--r--spec/factories/users.rb9
8 files changed, 74 insertions, 3 deletions
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb
index bacf163896c..4c1d5f07a42 100644
--- a/spec/factories/ci/bridge.rb
+++ b/spec/factories/ci/bridge.rb
@@ -7,7 +7,7 @@ FactoryBot.define do
stage_idx { 0 }
ref { 'master' }
tag { false }
- created_at { 'Di 29. Okt 09:50:00 CET 2013' }
+ created_at { '2013-10-29 09:50:00 CET' }
status { :created }
scheduling_type { 'stage' }
@@ -39,5 +39,19 @@ FactoryBot.define do
)
end
end
+
+ trait :started do
+ started_at { '2013-10-29 09:51:28 CET' }
+ end
+
+ trait :finished do
+ started
+ finished_at { '2013-10-29 09:53:28 CET' }
+ end
+
+ trait :failed do
+ finished
+ status { 'failed' }
+ end
end
end
diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb
index a259c5142fc..82383cfa2b0 100644
--- a/spec/factories/ci/job_artifacts.rb
+++ b/spec/factories/ci/job_artifacts.rb
@@ -13,7 +13,7 @@ FactoryBot.define do
end
trait :remote_store do
- file_store { JobArtifactUploader::Store::REMOTE }
+ file_store { JobArtifactUploader::Store::REMOTE}
end
after :build do |artifact|
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb
index 0a4f0fba9ab..728c83e01b4 100644
--- a/spec/factories/clusters/applications/helm.rb
+++ b/spec/factories/clusters/applications/helm.rb
@@ -139,5 +139,14 @@ FactoryBot.define do
cluster factory: %i(cluster provided_by_gcp)
end
end
+
+ factory :clusters_applications_fluentd, class: 'Clusters::Applications::Fluentd' do
+ host { 'example.com' }
+ cluster factory: %i(cluster with_installed_helm provided_by_gcp)
+
+ trait :no_helm_installed do
+ cluster factory: %i(cluster provided_by_gcp)
+ end
+ end
end
end
diff --git a/spec/factories/diff_position.rb b/spec/factories/diff_position.rb
index a43c5afdff4..685272acf5c 100644
--- a/spec/factories/diff_position.rb
+++ b/spec/factories/diff_position.rb
@@ -34,10 +34,20 @@ FactoryBot.define do
position_type { 'text' }
old_line { 10 }
new_line { 10 }
+ line_range { nil }
trait :added do
old_line { nil }
end
+
+ trait :multi_line do
+ line_range do
+ {
+ start_line_code: Gitlab::Git.diff_line_code(file, 10, 10),
+ end_line_code: Gitlab::Git.diff_line_code(file, 12, 13)
+ }
+ end
+ end
end
factory :image_diff_position do
diff --git a/spec/factories/import_failures.rb b/spec/factories/import_failures.rb
new file mode 100644
index 00000000000..376b2ff39e2
--- /dev/null
+++ b/spec/factories/import_failures.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'securerandom'
+
+FactoryBot.define do
+ factory :import_failure do
+ association :project, factory: :project
+
+ created_at { Time.parse('2020-01-01T00:00:00Z') }
+ exception_class { 'RuntimeError' }
+ exception_message { 'Something went wrong' }
+ source { 'method_call' }
+ correlation_id_value { SecureRandom.uuid }
+
+ trait :hard_failure do
+ retry_count { 0 }
+ end
+
+ trait :soft_failure do
+ retry_count { 1 }
+ end
+ end
+end
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index 2b468ef92e1..64321c9f319 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -37,6 +37,8 @@ FactoryBot.define do
group_runners_enabled { nil }
import_status { nil }
import_jid { nil }
+ import_correlation_id { nil }
+ import_last_error { nil }
forward_deployment_enabled { nil }
end
@@ -78,6 +80,8 @@ FactoryBot.define do
import_state = project.import_state || project.build_import_state
import_state.status = evaluator.import_status
import_state.jid = evaluator.import_jid
+ import_state.correlation_id_value = evaluator.import_correlation_id
+ import_state.last_error = evaluator.import_last_error
import_state.save
end
end
diff --git a/spec/factories/terraform/state.rb b/spec/factories/terraform/state.rb
index 4b83128ff6e..74950ccf93e 100644
--- a/spec/factories/terraform/state.rb
+++ b/spec/factories/terraform/state.rb
@@ -4,8 +4,10 @@ FactoryBot.define do
factory :terraform_state, class: 'Terraform::State' do
project { create(:project) }
+ sequence(:name) { |n| "state-#{n}" }
+
trait :with_file do
- file { fixture_file_upload('spec/fixtures/terraform/terraform.tfstate') }
+ file { fixture_file_upload('spec/fixtures/terraform/terraform.tfstate', 'application/json') }
end
end
end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index 0ce567e11fe..f274503f0e7 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -27,6 +27,10 @@ FactoryBot.define do
user_type { :alert_bot }
end
+ trait :project_bot do
+ user_type { :project_bot }
+ end
+
trait :external do
external { true }
end
@@ -83,12 +87,17 @@ FactoryBot.define do
transient do
developer_projects { [] }
+ maintainer_projects { [] }
end
after(:create) do |user, evaluator|
evaluator.developer_projects.each do |project|
project.add_developer(user)
end
+
+ evaluator.maintainer_projects.each do |project|
+ project.add_maintainer(user)
+ end
end
factory :omniauth_user do