Commit 91567eb3 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'clusters_with_all_applications_factory' into 'master'

Add and use clusters with_all_applications trait

See merge request gitlab-org/gitlab!33126
parents 956d3ec9 ad7779cd
......@@ -86,6 +86,19 @@ FactoryBot.define do
application_helm factory: %i(clusters_applications_helm installed)
end
trait :with_all_applications do
application_helm factory: %i(clusters_applications_helm installed)
application_ingress factory: %i(clusters_applications_ingress installed)
application_cert_manager factory: %i(clusters_applications_cert_manager installed)
application_crossplane factory: %i(clusters_applications_crossplane installed)
application_prometheus factory: %i(clusters_applications_prometheus installed)
application_runner factory: %i(clusters_applications_runner installed)
application_jupyter factory: %i(clusters_applications_jupyter installed)
application_knative factory: %i(clusters_applications_knative installed)
application_elastic_stack factory: %i(clusters_applications_elastic_stack installed)
application_fluentd factory: %i(clusters_applications_fluentd installed)
end
trait :with_domain do
domain { 'example.com' }
end
......
......@@ -608,19 +608,12 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
context 'when applications are created' do
let!(:helm) { create(:clusters_applications_helm, cluster: cluster) }
let!(:ingress) { create(:clusters_applications_ingress, cluster: cluster) }
let!(:cert_manager) { create(:clusters_applications_cert_manager, cluster: cluster) }
let!(:crossplane) { create(:clusters_applications_crossplane, cluster: cluster) }
let!(:prometheus) { create(:clusters_applications_prometheus, cluster: cluster) }
let!(:runner) { create(:clusters_applications_runner, cluster: cluster) }
let!(:jupyter) { create(:clusters_applications_jupyter, cluster: cluster) }
let!(:knative) { create(:clusters_applications_knative, cluster: cluster) }
let!(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: cluster) }
let!(:fluentd) { create(:clusters_applications_fluentd, cluster: cluster) }
let(:cluster) { create(:cluster, :with_all_applications) }
it 'returns a list of created applications' do
is_expected.to contain_exactly(helm, ingress, cert_manager, crossplane, prometheus, runner, jupyter, knative, elastic_stack, fluentd)
it 'returns a list of created applications', :aggregate_failures do
is_expected.to have_attributes(size: described_class::APPLICATIONS.size)
is_expected.to all(be_kind_of(::Clusters::Concerns::ApplicationCore))
is_expected.to all(be_persisted)
end
end
end
......@@ -646,33 +639,13 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
context 'when application is persisted' do
let!(:helm) { create(:clusters_applications_helm, cluster: cluster) }
let!(:ingress) { create(:clusters_applications_ingress, cluster: cluster) }
let!(:cert_manager) { create(:clusters_applications_cert_manager, cluster: cluster) }
let!(:crossplane) { create(:clusters_applications_crossplane, cluster: cluster) }
let!(:prometheus) { create(:clusters_applications_prometheus, cluster: cluster) }
let!(:runner) { create(:clusters_applications_runner, cluster: cluster) }
let!(:jupyter) { create(:clusters_applications_jupyter, cluster: cluster) }
let!(:knative) { create(:clusters_applications_knative, cluster: cluster) }
let!(:elastic_stack) { create(:clusters_applications_elastic_stack, cluster: cluster) }
let!(:fluentd) { create(:clusters_applications_fluentd, cluster: cluster) }
let(:cluster) { create(:cluster, :with_all_applications) }
it 'returns the persisted application', :aggregate_failures do
{
Clusters::Applications::Helm => helm,
Clusters::Applications::Ingress => ingress,
Clusters::Applications::CertManager => cert_manager,
Clusters::Applications::Crossplane => crossplane,
Clusters::Applications::Prometheus => prometheus,
Clusters::Applications::Runner => runner,
Clusters::Applications::Jupyter => jupyter,
Clusters::Applications::Knative => knative,
Clusters::Applications::ElasticStack => elastic_stack,
Clusters::Applications::Fluentd => fluentd
}.each do |application_class, expected_object|
described_class::APPLICATIONS.each_value do |application_class|
application = cluster.find_or_build_application(application_class)
expect(application).to eq(expected_object)
expect(application).to be_kind_of(::Clusters::Concerns::ApplicationCore)
expect(application).to be_persisted
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment