summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/metatype/instances.rb19
-rwxr-xr-xtest/ral/manager/instances.rb15
2 files changed, 29 insertions, 5 deletions
diff --git a/lib/puppet/metatype/instances.rb b/lib/puppet/metatype/instances.rb
index 7c951058c..f6c2fdd34 100644
--- a/lib/puppet/metatype/instances.rb
+++ b/lib/puppet/metatype/instances.rb
@@ -184,13 +184,22 @@ class Puppet::Type
end
# remove a specified object
- def self.delete(object)
+ def self.delete(resource)
return unless defined? @objects
- if @objects.include?(object.title)
- @objects.delete(object.title)
+ if @objects.include?(resource.title)
+ @objects.delete(resource.title)
end
- if @aliases.include?(object.title)
- @aliases.delete(object.title)
+ if @aliases.include?(resource.title)
+ @aliases.delete(resource.title)
+ end
+ if @aliases.has_value?(resource)
+ names = []
+ @aliases.each do |name, otherres|
+ if otherres == resource
+ names << name
+ end
+ end
+ names.each { |name| @aliases.delete(name) }
end
end
diff --git a/test/ral/manager/instances.rb b/test/ral/manager/instances.rb
index 759a5884a..e7a43488a 100755
--- a/test/ral/manager/instances.rb
+++ b/test/ral/manager/instances.rb
@@ -89,6 +89,21 @@ class TestTypeInstances < Test::Unit::TestCase
# Now make sure the resources have an 'ensure' property to go with the value in the provider
assert(resources[:one].send(:instance_variable_get, "@parameters").include?(:ensure), "Did not create ensure property")
end
+
+ # Make sure resources are entirely deleted.
+ def test_delete
+ aliases = %w{one}
+ obj = @type.create(:name => "testing", :alias => "two")
+ aliases << "two"
+
+ @type.alias("two", obj)
+
+ obj.remove
+ assert_nil(@type["testing"], "Object was not removed from objects hash")
+ assert_nil(@type["one"], "Object's alias was not removed")
+ assert_nil(@type["two"], "Object's second alias was not removed")
+
+ end
end
# $Id$