use CIB object class description to facilitate code reuse

This commit is contained in:
Adam Spiers 2014-02-06 18:09:24 +00:00
parent 6996e0dfeb
commit 14b4021a3b
2 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,7 @@ end
action :start do
name = new_resource.name
unless @current_resource
raise "Cannot start non-existent resource primitive '#{name}'"
raise "Cannot start non-existent #{cib_object_class.description} '#{name}'"
end
rsc = cib_object_class.new(name)
next if rsc.running?
@ -69,7 +69,7 @@ end
action :stop do
name = new_resource.name
unless @current_resource
raise "Cannot stop non-existent resource primitive '#{name}'"
raise "Cannot stop non-existent #{cib_object_class.description} '#{name}'"
end
rsc = cib_object_class.new(name)
next unless rsc.running?

View File

@ -121,7 +121,7 @@ describe "Chef::Provider::PacemakerPrimitive" do
expect_definition(definition)
expected_error = \
"Existing primitive resource '#{fixture.name}' has agent '#{existing_agent}' " \
"Existing #{fixture} has agent '#{existing_agent}' " \
"but recipe wanted '#{@resource.agent}'"
expect { provider.run_action :create }.to \
raise_error(RuntimeError, expected_error)
@ -138,7 +138,7 @@ describe "Chef::Provider::PacemakerPrimitive" do
expect_definition(fixture.definition_string)
expect_running(true)
expected_error = "Cannot delete running primitive resource '#{fixture.name}'"
expected_error = "Cannot delete running #{fixture}"
expect { provider.run_action :delete }.to \
raise_error(RuntimeError, expected_error)
@ -163,7 +163,7 @@ describe "Chef::Provider::PacemakerPrimitive" do
it_should_behave_like "action on non-existent resource", \
:start,
"crm resource start #{fixture.name}", \
"Cannot start non-existent resource primitive '#{fixture.name}'"
"Cannot start non-existent #{fixture}"
it "should do nothing to a started resource" do
expect_definition(fixture.definition_string)
@ -193,7 +193,7 @@ describe "Chef::Provider::PacemakerPrimitive" do
it_should_behave_like "action on non-existent resource", \
:stop,
"crm resource stop #{fixture.name}", \
"Cannot stop non-existent resource primitive '#{fixture.name}'"
"Cannot stop non-existent #{fixture}"
it "should do nothing to a stopped resource" do
expect_definition(fixture.definition_string)