diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-19 22:12:51 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-19 22:12:51 +0000 |
commit | 3f1c865eab38e6d41ff67de6730ca817ed09a02d (patch) | |
tree | a756357fdc93be5c1ea98e8f2a2979e18df2bc80 | |
parent | 55014a263da5dce5b4014babbda2ff412f6f82d5 (diff) | |
download | puppet-3f1c865eab38e6d41ff67de6730ca817ed09a02d.tar.gz puppet-3f1c865eab38e6d41ff67de6730ca817ed09a02d.tar.xz puppet-3f1c865eab38e6d41ff67de6730ca817ed09a02d.zip |
Fixing #725. I was apparently not deleting the alias I was creating to the components.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2718 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/metatype/instances.rb | 19 | ||||
-rwxr-xr-x | test/ral/manager/instances.rb | 15 |
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$ |