Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust EMS factories for the Configuration Management Provider
Browse files Browse the repository at this point in the history
skateman committed Mar 31, 2020
1 parent fc8e1db commit 4a9e1f9
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions spec/factories/ext_management_system.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FactoryBot.define do
factory :ext_management_system,
factory :ems_dummy,
:class => "ManageIQ::Providers::Vmware::InfraManager" do
# provider :factory => :provider_foreman
sequence(:name) { |n| "ems_#{seq_padded_for_sorting(n)}" }
sequence(:hostname) { |n| "ems-#{seq_padded_for_sorting(n)}" }
sequence(:ipaddress) { |n| ip_from_seq(n) }

zone { FactoryBot.create(:zone) }
storage_profiles { [] }

@@ -66,6 +66,21 @@
end
end

factory :ext_management_system, :parent => :ems_dummy do
sequence(:hostname) { |n| "ems-#{seq_padded_for_sorting(n)}" }
sequence(:ipaddress) { |n| ip_from_seq(n) }
end

# Some EMS subclasses depend in the existence of a provider which stores their hostname/ipaddress
# As the order of attributes is important, it's not enough to just add the provider attribute into
# the child factory, it has to preceed the `hostname` and `ipaddress` attributes. If the order is
# not correct, a delegation error happens and the factory cannot be built.
factory :ext_management_system_with_provider, :parent => :ems_dummy do
provider
sequence(:hostname) { |n| "ems-#{seq_padded_for_sorting(n)}" }
sequence(:ipaddress) { |n| ip_from_seq(n) }
end

# Intermediate classes
# using leaf classes...
factory :ems_infra,
@@ -92,8 +107,6 @@
parent_manager { FactoryBot.create(:ext_management_system) }
end



factory :ems_storage,
:aliases => ["manageiq/providers/storage_manager"],
:class => "ManageIQ::Providers::StorageManager::SwiftManager",
@@ -123,7 +136,7 @@
factory :configuration_manager,
:aliases => ["manageiq/providers/configuration_manager"],
:class => "ManageIQ::Providers::Foreman::ConfigurationManager",
:parent => :ext_management_system
:parent => :ext_management_system_with_provider

# Automation managers

@@ -333,18 +346,18 @@
end
end


factory :ems_openshift,
:aliases => ["manageiq/providers/openshift/container_manager"],
:class => "ManageIQ::Providers::Openshift::ContainerManager",
:parent => :ems_container

# Leaf classes for configuration_manager

factory :configuration_manager_foreman,
:aliases => ["manageiq/providers/foreman/configuration_manager"],
:class => "ManageIQ::Providers::Foreman::ConfigurationManager",
:parent => :configuration_manager
:parent => :configuration_manager do
provider :factory => :provider_foreman
end

trait(:provider) do
after(:build, &:create_provider)

0 comments on commit 4a9e1f9

Please sign in to comment.