eliminate code duplication with shared context for LWRP tests
This commit is contained in:
@@ -1,5 +1,27 @@
|
||||
# Shared code used to test providers of CIB objects
|
||||
|
||||
require File.expand_path('../helpers/cib_object', File.dirname(__FILE__))
|
||||
|
||||
shared_context "a Pacemaker LWRP" do
|
||||
before(:each) do
|
||||
runner_opts = {
|
||||
:step_into => [lwrp_name]
|
||||
}
|
||||
@chef_run = ::ChefSpec::Runner.new(runner_opts)
|
||||
@chef_run.converge "pacemaker::default"
|
||||
@node = @chef_run.node
|
||||
@run_context = @chef_run.run_context
|
||||
|
||||
camelized_subclass_name = "Pacemaker" + lwrp_name.capitalize
|
||||
@resource_class = ::Chef::Resource.const_get(camelized_subclass_name)
|
||||
@provider_class = ::Chef::Provider.const_get(camelized_subclass_name)
|
||||
|
||||
@resource = @resource_class.new(fixture.name, @run_context)
|
||||
end
|
||||
|
||||
let (:provider) { @provider_class.new(@resource, @run_context) }
|
||||
end
|
||||
|
||||
shared_examples "action on non-existent resource" do |action, cmd, expected_error|
|
||||
include Chef::RSpec::Pacemaker::CIBObject
|
||||
|
||||
|
@@ -8,22 +8,17 @@ describe "Chef::Provider::PacemakerClone" do
|
||||
# for use outside examples (e.g. when invoking shared_examples)
|
||||
fixture = Chef::RSpec::Pacemaker::Config::CLONE_RESOURCE.dup
|
||||
|
||||
before(:each) do
|
||||
runner_opts = {
|
||||
:step_into => ['pacemaker_clone']
|
||||
}
|
||||
@chef_run = ::ChefSpec::Runner.new(runner_opts)
|
||||
@chef_run.converge "pacemaker::default"
|
||||
@node = @chef_run.node
|
||||
@run_context = @chef_run.run_context
|
||||
def lwrp_name
|
||||
'clone'
|
||||
end
|
||||
|
||||
@resource = Chef::Resource::PacemakerClone.new(fixture.name, @run_context)
|
||||
include_context "a Pacemaker LWRP"
|
||||
|
||||
before(:each) do
|
||||
@resource.rsc fixture.rsc.dup
|
||||
@resource.meta Hash[fixture.meta.dup]
|
||||
end
|
||||
|
||||
let (:provider) { Chef::Provider::PacemakerClone.new(@resource, @run_context) }
|
||||
|
||||
def cib_object_class
|
||||
Pacemaker::Resource::Clone
|
||||
end
|
||||
|
@@ -8,22 +8,17 @@ describe "Chef::Provider::PacemakerColocation" do
|
||||
# for use outside examples (e.g. when invoking shared_examples)
|
||||
fixture = Chef::RSpec::Pacemaker::Config::COLOCATION_CONSTRAINT.dup
|
||||
|
||||
before(:each) do
|
||||
runner_opts = {
|
||||
:step_into => ['pacemaker_colocation']
|
||||
}
|
||||
@chef_run = ::ChefSpec::Runner.new(runner_opts)
|
||||
@chef_run.converge "pacemaker::default"
|
||||
@node = @chef_run.node
|
||||
@run_context = @chef_run.run_context
|
||||
def lwrp_name
|
||||
'colocation'
|
||||
end
|
||||
|
||||
@resource = Chef::Resource::PacemakerColocation.new(fixture.name, @run_context)
|
||||
include_context "a Pacemaker LWRP"
|
||||
|
||||
before(:each) do
|
||||
@resource.score fixture.score
|
||||
@resource.resources fixture.resources.dup
|
||||
end
|
||||
|
||||
let (:provider) { Chef::Provider::PacemakerColocation.new(@resource, @run_context) }
|
||||
|
||||
def cib_object_class
|
||||
Pacemaker::Constraint::Colocation
|
||||
end
|
||||
|
@@ -8,22 +8,17 @@ describe "Chef::Provider::PacemakerGroup" do
|
||||
# for use outside examples (e.g. when invoking shared_examples)
|
||||
fixture = Chef::RSpec::Pacemaker::Config::RESOURCE_GROUP.dup
|
||||
|
||||
before(:each) do
|
||||
runner_opts = {
|
||||
:step_into => ['pacemaker_group']
|
||||
}
|
||||
@chef_run = ::ChefSpec::Runner.new(runner_opts)
|
||||
@chef_run.converge "pacemaker::default"
|
||||
@node = @chef_run.node
|
||||
@run_context = @chef_run.run_context
|
||||
def lwrp_name
|
||||
'group'
|
||||
end
|
||||
|
||||
@resource = Chef::Resource::PacemakerGroup.new(fixture.name, @run_context)
|
||||
include_context "a Pacemaker LWRP"
|
||||
|
||||
before(:each) do
|
||||
@resource.members fixture.members.dup
|
||||
@resource.meta Hash[fixture.meta.dup]
|
||||
end
|
||||
|
||||
let (:provider) { Chef::Provider::PacemakerGroup.new(@resource, @run_context) }
|
||||
|
||||
def cib_object_class
|
||||
Pacemaker::Resource::Group
|
||||
end
|
||||
|
@@ -8,23 +8,18 @@ describe "Chef::Provider::PacemakerLocation" do
|
||||
# for use outside examples (e.g. when invoking shared_examples)
|
||||
fixture = Chef::RSpec::Pacemaker::Config::LOCATION_CONSTRAINT.dup
|
||||
|
||||
before(:each) do
|
||||
runner_opts = {
|
||||
:step_into => ['pacemaker_location']
|
||||
}
|
||||
@chef_run = ::ChefSpec::Runner.new(runner_opts)
|
||||
@chef_run.converge "pacemaker::default"
|
||||
@node = @chef_run.node
|
||||
@run_context = @chef_run.run_context
|
||||
def lwrp_name
|
||||
'location'
|
||||
end
|
||||
|
||||
@resource = Chef::Resource::PacemakerLocation.new(fixture.name, @run_context)
|
||||
include_context "a Pacemaker LWRP"
|
||||
|
||||
before(:each) do
|
||||
@resource.rsc fixture.rsc
|
||||
@resource.score fixture.score
|
||||
@resource.node fixture.node.dup
|
||||
end
|
||||
|
||||
let (:provider) { Chef::Provider::PacemakerLocation.new(@resource, @run_context) }
|
||||
|
||||
def cib_object_class
|
||||
Pacemaker::Constraint::Location
|
||||
end
|
||||
|
@@ -8,22 +8,17 @@ describe "Chef::Provider::PacemakerMs" do
|
||||
# for use outside examples (e.g. when invoking shared_examples)
|
||||
fixture = Chef::RSpec::Pacemaker::Config::MS_RESOURCE.dup
|
||||
|
||||
before(:each) do
|
||||
runner_opts = {
|
||||
:step_into => ['pacemaker_ms']
|
||||
}
|
||||
@chef_run = ::ChefSpec::Runner.new(runner_opts)
|
||||
@chef_run.converge "pacemaker::default"
|
||||
@node = @chef_run.node
|
||||
@run_context = @chef_run.run_context
|
||||
def lwrp_name
|
||||
'ms'
|
||||
end
|
||||
|
||||
@resource = Chef::Resource::PacemakerMs.new(fixture.name, @run_context)
|
||||
include_context "a Pacemaker LWRP"
|
||||
|
||||
before(:each) do
|
||||
@resource.rsc fixture.rsc.dup
|
||||
@resource.meta Hash[fixture.meta.dup]
|
||||
end
|
||||
|
||||
let (:provider) { Chef::Provider::PacemakerMs.new(@resource, @run_context) }
|
||||
|
||||
def cib_object_class
|
||||
Pacemaker::Resource::MasterSlave
|
||||
end
|
||||
|
@@ -8,24 +8,19 @@ describe "Chef::Provider::PacemakerPrimitive" do
|
||||
# for use outside examples (e.g. when invoking shared_examples)
|
||||
fixture = Chef::RSpec::Pacemaker::Config::KEYSTONE_PRIMITIVE
|
||||
|
||||
before(:each) do
|
||||
runner_opts = {
|
||||
:step_into => ['pacemaker_primitive']
|
||||
}
|
||||
@chef_run = ::ChefSpec::Runner.new(runner_opts)
|
||||
@chef_run.converge "pacemaker::default"
|
||||
@node = @chef_run.node
|
||||
@run_context = @chef_run.run_context
|
||||
def lwrp_name
|
||||
'primitive'
|
||||
end
|
||||
|
||||
@resource = Chef::Resource::PacemakerPrimitive.new(fixture.name, @run_context)
|
||||
include_context "a Pacemaker LWRP"
|
||||
|
||||
before(:each) do
|
||||
@resource.agent fixture.agent
|
||||
@resource.params Hash[fixture.params]
|
||||
@resource.meta Hash[fixture.meta]
|
||||
@resource.op Hash[fixture.op]
|
||||
end
|
||||
|
||||
let (:provider) { Chef::Provider::PacemakerPrimitive.new(@resource, @run_context) }
|
||||
|
||||
def cib_object_class
|
||||
Pacemaker::Resource::Primitive
|
||||
end
|
||||
|
Reference in New Issue
Block a user