debian-mirror-gitlab/spec/factories/clusters/clusters.rb

73 lines
1.8 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
FactoryBot.define do
factory :cluster, class: Clusters::Cluster do
user
name 'test-cluster'
2018-12-13 13:39:08 +05:30
cluster_type :project_type
2019-07-07 11:18:12 +05:30
managed true
2018-12-13 13:39:08 +05:30
trait :instance do
cluster_type { Clusters::Cluster.cluster_types[:instance_type] }
end
2018-03-17 18:26:18 +05:30
trait :project do
2018-12-13 13:39:08 +05:30
cluster_type { Clusters::Cluster.cluster_types[:project_type] }
2018-11-08 19:23:39 +05:30
before(:create) do |cluster, evaluator|
2019-07-07 11:18:12 +05:30
cluster.projects << create(:project, :repository) unless cluster.projects.present?
2018-03-17 18:26:18 +05:30
end
end
2018-12-13 13:39:08 +05:30
trait :group do
cluster_type { Clusters::Cluster.cluster_types[:group_type] }
before(:create) do |cluster, evalutor|
2019-07-07 11:18:12 +05:30
cluster.groups << create(:group) unless cluster.groups.present?
2018-12-13 13:39:08 +05:30
end
end
2018-03-17 18:26:18 +05:30
trait :provided_by_user do
provider_type :user
platform_type :kubernetes
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
end
trait :provided_by_gcp do
provider_type :gcp
platform_type :kubernetes
provider_gcp factory: [:cluster_provider_gcp, :created]
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
end
trait :providing_by_gcp do
provider_type :gcp
provider_gcp factory: [:cluster_provider_gcp, :creating]
end
2019-02-15 15:39:39 +05:30
trait :rbac_disabled do
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured, :rbac_disabled]
end
2018-03-17 18:26:18 +05:30
trait :disabled do
enabled false
end
2018-05-01 15:08:00 +05:30
trait :production_environment do
sequence(:environment_scope) { |n| "production#{n}/*" }
end
2018-11-18 11:00:15 +05:30
trait :with_installed_helm do
application_helm factory: %i(clusters_applications_helm installed)
end
2019-03-02 22:35:43 +05:30
trait :with_domain do
domain 'example.com'
end
2019-07-07 11:18:12 +05:30
2019-07-31 22:56:46 +05:30
trait :not_managed do
2019-07-07 11:18:12 +05:30
managed false
end
2018-03-17 18:26:18 +05:30
end
end