diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-08-17 05:08:36 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-08-17 05:08:36 +0000 |
commit | beba3e480c7ad7f942414a8aa31f96b5b42b53e4 (patch) | |
tree | d3c2949930af4462b5a1d03a46b0f8d76e087d0c | |
parent | 607d7c6afec7ab73203382676cc98b6d52898e1d (diff) | |
download | puppet-beba3e480c7ad7f942414a8aa31f96b5b42b53e4.tar.gz puppet-beba3e480c7ad7f942414a8aa31f96b5b42b53e4.tar.xz puppet-beba3e480c7ad7f942414a8aa31f96b5b42b53e4.zip |
Finishing changes to support titles instead of two types of names. This is basically a bug-fix commit.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1472 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | examples/code/snippets/argumentdefaults | 2 | ||||
-rw-r--r-- | examples/code/snippets/defineoverrides.pp | 2 | ||||
-rw-r--r-- | examples/code/snippets/failmissingexecpath.pp | 2 | ||||
-rw-r--r-- | examples/code/snippets/namevartest | 2 | ||||
-rw-r--r-- | lib/puppet/type.rb | 101 | ||||
-rw-r--r-- | lib/puppet/type/component.rb | 36 | ||||
-rw-r--r-- | lib/puppet/type/pfile.rb | 11 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/checksum.rb | 8 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/content.rb | 2 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/ensure.rb | 4 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/source.rb | 4 | ||||
-rwxr-xr-x | lib/puppet/type/symlink.rb | 7 | ||||
-rw-r--r-- | test/other/transactions.rb | 2 | ||||
-rw-r--r-- | test/puppettest.rb | 6 | ||||
-rwxr-xr-x | test/types/exec.rb | 31 | ||||
-rw-r--r-- | test/types/file.rb | 17 | ||||
-rwxr-xr-x | test/types/filesources.rb | 8 | ||||
-rwxr-xr-x | test/types/symlink.rb | 2 | ||||
-rw-r--r-- | test/types/type.rb | 32 |
19 files changed, 170 insertions, 109 deletions
diff --git a/examples/code/snippets/argumentdefaults b/examples/code/snippets/argumentdefaults index 7d814f2fb..eac9dd757 100644 --- a/examples/code/snippets/argumentdefaults +++ b/examples/code/snippets/argumentdefaults @@ -1,6 +1,6 @@ # $Id$ -define testargs(file, mode = 755) { +define testargs($file, $mode = 755) { file { $file: ensure => file, mode => $mode } } diff --git a/examples/code/snippets/defineoverrides.pp b/examples/code/snippets/defineoverrides.pp index ff598eb69..1b6561668 100644 --- a/examples/code/snippets/defineoverrides.pp +++ b/examples/code/snippets/defineoverrides.pp @@ -2,7 +2,7 @@ $file = "/tmp/defineoverrides1" -define myfile(mode) { +define myfile($mode) { file { $name: ensure => file, mode => $mode } } diff --git a/examples/code/snippets/failmissingexecpath.pp b/examples/code/snippets/failmissingexecpath.pp index fe17b049b..ca5b25f4c 100644 --- a/examples/code/snippets/failmissingexecpath.pp +++ b/examples/code/snippets/failmissingexecpath.pp @@ -1,4 +1,4 @@ -define distloc(path) { +define distloc($path) { file { "/tmp/exectesting1": ensure => file } diff --git a/examples/code/snippets/namevartest b/examples/code/snippets/namevartest index b4db5bacf..dbee1c356 100644 --- a/examples/code/snippets/namevartest +++ b/examples/code/snippets/namevartest @@ -1,4 +1,4 @@ -define filetest(mode, ensure = file) { +define filetest($mode, $ensure = file) { file { $name: mode => $mode, ensure => $ensure diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index b39950f7e..2ebc2b977 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -331,8 +331,11 @@ class Type < Puppet::Element # remove a specified object def self.delete(object) return unless defined? @objects - if @objects.include?(object.name) - @objects.delete(object.name) + if @objects.include?(object.title) + @objects.delete(object.title) + end + if @aliases.include?(object.title) + @aliases.delete(object.title) end end @@ -790,20 +793,22 @@ class Type < Puppet::Element # What type of parameter are we dealing with? Cache the results, because # this method gets called so many times. - def self.attrtype(name) + def self.attrtype(attr) @attrtypes ||= {} - unless @attrtypes.include?(name) - @attrtypes[name] = case - when @validstates.include?(name): :state - when @@metaparamhash.include?(name): :meta - when @paramhash.include?(name): :param + unless @attrtypes.include?(attr) + @attrtypes[attr] = case + when @validstates.include?(attr): :state + when @@metaparamhash.include?(attr): :meta + when @paramhash.include?(attr): :param else - raise Puppet::DevError, "Invalid attribute '%s' for class '%s'" % - [name, self.name] + Puppet.err "raising a warning, yo: %s" % attr + raise Puppet::DevError, + "Invalid attribute '%s' for class '%s'" % + [attr, self.name] end end - @attrtypes[name] + @attrtypes[attr] end # All parameters, in the appropriate order. The namevar comes first, @@ -1177,7 +1182,7 @@ class Type < Puppet::Element def parent=(parent) if self.parentof?(parent) devfail "%s[%s] is already the parent of %s[%s]" % - [self.class.name, self.name, parent.class.name, parent.name] + [self.class.name, self.title, parent.class.name, parent.title] end @parent = parent end @@ -1205,7 +1210,7 @@ class Type < Puppet::Element childs.each { |child| # Make sure we don't have any loops here. if parentof?(child) - devfail "Already the parent of %s[%s]" % [child.class.name, child.name] + devfail "Already the parent of %s[%s]" % [child.class.name, child.title] end unless child.is_a?(Puppet::Element) self.debug "Got object of type %s" % child.class @@ -1351,8 +1356,6 @@ class Type < Puppet::Element name = nil unless hash.is_a? TransObject - # if it's not a transobject, then make it one, just to make people's - # lives easier hash = self.hash2trans(hash) end @@ -1422,13 +1425,22 @@ class Type < Puppet::Element # Convert a hash to a TransObject. def self.hash2trans(hash) title = nil - [:title, self.namevar, :name].each { |param| - if hash.include? param - title = hash[param] - hash.delete(param) - break + if hash.include? :title + title = hash[:title] + hash.delete(:title) + elsif hash.include? self.namevar + title = hash[self.namevar] + hash.delete(self.namevar) + + if hash.include? :name + raise ArgumentError, "Cannot provide both name and %s to %s" % + [self.namevar, self.name] end - } + elsif hash[:name] + title = hash[:name] + hash.delete :name + end + unless title raise Puppet::Error, "You must specify a title for objects of type %s" % self.to_s @@ -1531,6 +1543,7 @@ class Type < Puppet::Element namevar = self.class.namevar orighash = hash + # If we got passed a transportable object, we just pull a bunch of info # directly from it. This is the main object instantiation mechanism. if hash.is_a?(Puppet::TransObject) @@ -1562,16 +1575,16 @@ class Type < Puppet::Element # Munge up the namevar stuff so we only have one value. hash = self.argclean(hash) - # If we've got a title via some other mechanism, set it as an alias. - if defined? @title and @title - if aliases = hash[:alias] - aliases = [aliases] unless aliases.is_a? Array - aliases << @title - hash[:alias] = aliases - else - hash[:alias] = @title - end - end + # If we've got both a title via some other mechanism, set it as an alias. +# if defined? @title and @title and ! hash[:name] +# if aliases = hash[:alias] +# aliases = [aliases] unless aliases.is_a? Array +# aliases << @title +# hash[:alias] = aliases +# else +# hash[:alias] = @title +# end +# end # Let's do the name first, because some things need to happen once # we have the name but before anything else @@ -1591,6 +1604,10 @@ class Type < Puppet::Element self.devfail "I was not passed a namevar" end + if self.name != self.title + self.class.alias(self.name, self) + end + # The information to cache to disk. We have to do this after # the name is set because it uses the name and/or path, but before # everything else is set because the states need to be able to @@ -1653,7 +1670,7 @@ class Type < Puppet::Element # Now change our dependency to just the string, instead of # the object itself. - dep = dep.name + dep = dep.title else # Skip autorequires that we aren't managing unless obj = typeobj[dep] @@ -1664,7 +1681,7 @@ class Type < Puppet::Element # Skip autorequires that we already require next if self.requires?(obj) - debug "Autorequiring %s %s" % [obj.class.name, obj.name] + debug "Autorequiring %s %s" % [obj.class.name, obj.title] self[:require] = [type, dep] } @@ -1797,6 +1814,7 @@ class Type < Puppet::Element obj.value = value else #self.debug "No default for %s" % obj.name + # "obj" is a Parameter. self.delete(obj.name) end } @@ -1834,10 +1852,10 @@ class Type < Puppet::Element newvals = oldvals & value if newvals.empty? self.fail "No common values for %s on %s(%s)" % - [param, self.class.name, self.name] + [param, self.class.name, self.title] elsif newvals.length > 1 self.fail "Too many values for %s on %s(%s)" % - [param, self.class.name, self.name] + [param, self.class.name, self.title] else self.debug "Reduced old values %s and new values %s to %s" % [oldvals.inspect, value.inspect, newvals.inspect] @@ -1909,6 +1927,9 @@ class Type < Puppet::Element # Do a simple translation for those cases where they've passed :name # but that's not our namevar if hash.include? :name and namevar != :name + if hash.include? namevar + raise ArgumentError, "Cannot provide both name and %s" % namevar + end hash[namevar] = hash[:name] hash.delete(:name) end @@ -1937,7 +1958,7 @@ class Type < Puppet::Element # convert to a string def to_s - self.name + self.title end # Convert to a transportable object @@ -1945,7 +1966,7 @@ class Type < Puppet::Element # Collect all of the "is" values retrieve() - trans = TransObject.new(self.name, self.class.name) + trans = TransObject.new(self.title, self.class.name) states().each do |state| trans[state.name] = state.is @@ -1953,7 +1974,7 @@ class Type < Puppet::Element @parameters.each do |name, param| # Avoid adding each instance name as both the name and the namevar - next if param.class.isnamevar? and param.value == self.name + next if param.class.isnamevar? and param.value == self.title trans[name] = param.value end @@ -2031,7 +2052,7 @@ class Type < Puppet::Element #Puppet.err "Evaluating %s" % self.path.join(":") unless defined? @evalcount self.err "No evalcount defined on '%s' of type '%s'" % - [self.name,self.class] + [self.title,self.class] @evalcount = 0 end @evalcount += 1 @@ -2516,7 +2537,7 @@ class Type < Puppet::Element unless obj == @parent self.fail( "%s can not create alias %s: object already exists" % - [@parent.name, other] + [@parent.title, other] ) end next diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb index 9123bbe75..c159ccc83 100644 --- a/lib/puppet/type/component.rb +++ b/lib/puppet/type/component.rb @@ -73,6 +73,16 @@ module Puppet @children.each { |child| yield child } end + # flatten all children, sort them, and evaluate them in order + # this is only called on one component over the whole system + # this also won't work with scheduling, but eh + def evaluate + self.finalize unless self.finalized? + transaction = Puppet::Transaction.new(self.flatten) + transaction.component = self + return transaction + end + # Do all of the polishing off, mostly doing autorequires and making # dependencies. This will get run once on the top-level component, # and it will do everything necessary. @@ -84,7 +94,7 @@ module Puppet self.delve do |object| # Make sure we don't get into loops if started.has_key?(object) - debug "Already finished %s" % object.name + debug "Already finished %s" % object.title next else started[object] = true @@ -119,26 +129,16 @@ module Puppet super(args) end - # flatten all children, sort them, and evaluate them in order - # this is only called on one component over the whole system - # this also won't work with scheduling, but eh - def evaluate - self.finalize unless self.finalized? - transaction = Puppet::Transaction.new(self.flatten) - transaction.component = self - return transaction - end - - def name - #return self[:name] - unless defined? @name + # We have a different way of setting the title + def title + unless defined? @title if self[:type] == self[:name] or self[:name] =~ /--\d+$/ - @name = self[:type] + @title = self[:type] else - @name = "%s[%s]" % [self[:type],self[:name]] + @title = "%s[%s]" % [self[:type],self[:name]] end end - return @name + return @title end def refresh @@ -151,7 +151,7 @@ module Puppet end def to_s - return "component(%s)" % self.name + return "component(%s)" % self.title end end end diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index ee84b0699..a6892c88e 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -369,6 +369,10 @@ module Puppet def initialize(hash) # Store a copy of the arguments for later. tmphash = hash.to_hash + + # Used for caching clients + @clients = {} + super # Clean out as many references to any file paths as possible. # This was the source of many, many bugs. @@ -379,10 +383,11 @@ module Puppet @arghash.delete(:source) end - @stat = nil + if @arghash.include?(:parent) + @arghash.delete(:parent) + end - # Used for caching clients - @clients = {} + @stat = nil end # Create a new file or directory object as a child to the current diff --git a/lib/puppet/type/pfile/checksum.rb b/lib/puppet/type/pfile/checksum.rb index d5de955e6..cd82a4439 100755 --- a/lib/puppet/type/pfile/checksum.rb +++ b/lib/puppet/type/pfile/checksum.rb @@ -183,7 +183,7 @@ module Puppet def handlesum if @is.nil? raise Puppet::Error, "Checksum state for %s is somehow nil" % - @parent.name + @parent.title end if @is == :absent @@ -277,14 +277,14 @@ module Puppet result = false state = nil unless state = @parent.cached(:checksums) - self.debug "Initializing checksum hash for %s" % @parent.name + self.debug "Initializing checksum hash for %s" % @parent.title state = {} @parent.cache(:checksums, state) end if @is.is_a?(Symbol) error = Puppet::Error.new("%s has invalid checksum" % - @parent.name) + @parent.title) raise error end @@ -297,7 +297,7 @@ module Puppet ) end self.debug "Replacing %s checksum %s with %s" % - [@parent.name, state[@checktypes[0]],@is] + [@parent.title, state[@checktypes[0]],@is] #@parent.debug "@is: %s; @should: %s" % [@is,@should] result = true else diff --git a/lib/puppet/type/pfile/content.rb b/lib/puppet/type/pfile/content.rb index 67840361b..5853b99f6 100755 --- a/lib/puppet/type/pfile/content.rb +++ b/lib/puppet/type/pfile/content.rb @@ -49,7 +49,7 @@ module Puppet rescue => detail @is = nil raise Puppet::Error, "Could not read %s: %s" % - [@parent.name, detail] + [@parent.title, detail] end end diff --git a/lib/puppet/type/pfile/ensure.rb b/lib/puppet/type/pfile/ensure.rb index d15d1c6b9..f22e43637 100755 --- a/lib/puppet/type/pfile/ensure.rb +++ b/lib/puppet/type/pfile/ensure.rb @@ -112,11 +112,11 @@ module Puppet if ! FileTest.exists?(basedir) raise Puppet::Error, "Can not create %s; parent directory does not exist" % - @parent.name + @parent.title elsif ! FileTest.directory?(basedir) raise Puppet::Error, "Can not create %s; %s is not a directory" % - [@parent.name, dirname] + [@parent.title, dirname] end end diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb index 606d8ec32..2bdce9240 100755 --- a/lib/puppet/type/pfile/source.rb +++ b/lib/puppet/type/pfile/source.rb @@ -78,7 +78,7 @@ module Puppet unless defined? @shouldorig raise Puppet::DevError, "No sources defined for %s" % - @parent.name + @parent.title end @source = nil unless defined? @source @@ -211,7 +211,7 @@ module Puppet self.retrieve # try again if @is == :notdescribed @parent.log "Could not retreive information on %s" % - @parent.name + @parent.title return nil end if @is == @should diff --git a/lib/puppet/type/symlink.rb b/lib/puppet/type/symlink.rb index 356fd6688..63f109dcf 100755 --- a/lib/puppet/type/symlink.rb +++ b/lib/puppet/type/symlink.rb @@ -176,9 +176,12 @@ module Puppet end def initialize(hash) - @arghash = self.argclean(hash.dup) - @arghash.delete(self.class.namevar) + tmphash = hash.to_hash super + @arghash = tmphash + @arghash.delete(self.class.namevar) + #@arghash = self.argclean(hash.dup) + #@arghash.delete(self.class.namevar) end end # Puppet.type(:symlink) end diff --git a/test/other/transactions.rb b/test/other/transactions.rb index c4b461a86..02acaa8e7 100644 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -384,7 +384,7 @@ class TestTransactions < Test::Unit::TestCase def test_failed_reqs_mean_no_run exec = Puppet::Type.type(:exec).create( :command => "/bin/mkdir /this/path/cannot/possibly/exit", - :name => "mkdir" + :title => "mkdir" ) file = Puppet::Type.type(:file).create( diff --git a/test/puppettest.rb b/test/puppettest.rb index a49ceb175..eb2699073 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -112,7 +112,7 @@ module TestPuppet if ary[0].is_a?(String) name = ary.shift else - name = ary[0].name + name = ary[0].title end comp = Puppet.type(:component).create( @@ -335,10 +335,10 @@ module TestPuppet if items[0].is_a? Puppet.type(:component) comp = items.shift else - comp = newcomp(items[0].name, *items) + comp = newcomp(items[0].title, *items) remove_comp = true end - msg ||= comp.name + msg ||= comp.title assert_nothing_raised("Component %s failed" % [msg]) { trans = comp.evaluate } diff --git a/test/types/exec.rb b/test/types/exec.rb index f9f7592e3..4f66da517 100755 --- a/test/types/exec.rb +++ b/test/types/exec.rb @@ -200,13 +200,13 @@ class TestExec < Test::Unit::TestCase File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" } file = Puppet.type(:file).create( - :name => oexe, + :path => oexe, :source => exe, :mode => 0755 ) exec = Puppet.type(:exec).create( - :name => oexe, + :command => oexe, :require => [:file, oexe] ) @@ -223,31 +223,31 @@ class TestExec < Test::Unit::TestCase File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" } file = Puppet.type(:file).create( - :name => oexe, + :path => oexe, :source => exe, :mode => 755 ) basedir = File.dirname(oexe) baseobj = Puppet.type(:file).create( - :name => basedir, + :path => basedir, :source => exe, :mode => 755 ) ofile = Puppet.type(:file).create( - :name => exe, + :path => exe, :mode => 755 ) exec = Puppet.type(:exec).create( - :name => oexe, + :command => oexe, :path => ENV["PATH"], :cwd => basedir ) cat = Puppet.type(:exec).create( - :name => "cat %s %s" % [exe, oexe], + :command => "cat %s %s" % [exe, oexe], :path => ENV["PATH"] ) @@ -302,15 +302,16 @@ class TestExec < Test::Unit::TestCase :path => ENV['PATH'] ) } + comp = newcomp(exec) - assert_events([:executed_command], exec) - assert_events([:executed_command], exec) + assert_events([:executed_command], comp) + assert_events([:executed_command], comp) system("touch %s" % afile) - assert_events([], exec) - assert_events([], exec) + assert_events([], comp) + assert_events([], comp) system("rm %s" % afile) - assert_events([:executed_command], exec) - assert_events([:executed_command], exec) + assert_events([:executed_command], comp) + assert_events([:executed_command], comp) end if Process.uid == 0 @@ -377,7 +378,7 @@ class TestExec < Test::Unit::TestCase exec = nil assert_nothing_raised { exec = Puppet.type(:exec).create( - :name => "logoutputesting", + :title => "logoutputesting", :path => "/usr/bin:/bin", :command => "echo logoutput is false", :logoutput => false @@ -408,7 +409,7 @@ class TestExec < Test::Unit::TestCase path = File.join(basedir, "subfile") assert_nothing_raised { exec = Puppet.type(:exec).create( - :name => "mkdir", + :title => "mkdir", :path => "/usr/bin:/bin", :creates => basedir, :command => "mkdir %s; touch %s" % [basedir, path] diff --git a/test/types/file.rb b/test/types/file.rb index 34fba29fb..eeb976370 100644 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -151,7 +151,7 @@ class TestFile < Test::Unit::TestCase obj = nil assert_nothing_raised { obj = Puppet.type(:file).create( - :name => link, + :title => link, :owner => user.name ) } @@ -327,7 +327,7 @@ class TestFile < Test::Unit::TestCase def test_modes file = mktestfile # Set it to something else initially - File.chmod(0775, file.name) + File.chmod(0775, file.title) [0644,0755,0777,0641].each { |mode| assert_nothing_raised() { file[:mode] = mode @@ -380,7 +380,7 @@ class TestFile < Test::Unit::TestCase file.retrieve - if file.name !~ /nonexists/ + if file.title !~ /nonexists/ sum = file.state(:checksum) assert_equal(sum.is, sum.should) assert(sum.insync?) @@ -664,7 +664,7 @@ class TestFile < Test::Unit::TestCase assert(file, "Could not retrieve file object") - assert_equal("file=%s" % file.name, file.path) + assert_equal("file=%s" % file.title, file.path) end def test_autorequire @@ -817,7 +817,7 @@ class TestFile < Test::Unit::TestCase file = nil assert_nothing_raised { file = Puppet.type(:file).create( - :name => "fileness", + :title => "fileness", :path => path, :content => "this is some content" ) @@ -868,7 +868,7 @@ class TestFile < Test::Unit::TestCase obj = nil assert_nothing_raised { obj = Puppet.type(:file).create( - :name => link, + :path => link, :mode => "755" ) } @@ -1122,7 +1122,7 @@ class TestFile < Test::Unit::TestCase bpath = tempfile() Dir.mkdir(bpath) Puppet::Type.type(:filebucket).create( - :name => bucket, :path => bpath + :title => bucket, :path => bpath ) obj[:backup] = bucket @@ -1144,7 +1144,7 @@ class TestFile < Test::Unit::TestCase } obj = Puppet::Type.type(:file).create( - :name => dest, :source => source + :title => dest, :source => source ) assert_events([:file_created], obj) @@ -1304,6 +1304,7 @@ class TestFile < Test::Unit::TestCase :path => dest, :source => source ) + assert(obj, "Did not create file") assert_apply(obj) diff --git a/test/types/filesources.rb b/test/types/filesources.rb index b69e83008..8c1d40b6f 100755 --- a/test/types/filesources.rb +++ b/test/types/filesources.rb @@ -100,10 +100,10 @@ class TestFileSources < Test::Unit::TestCase assert_nothing_raised { tofile = Puppet.type(:file).create( - :name => todir, - "recurse" => true, - "backup" => false, - "source" => fromdir + :path => todir, + :recurse => true, + :backup => false, + :source => fromdir ) } assert_apply(tofile) diff --git a/test/types/symlink.rb b/test/types/symlink.rb index c44668448..408817cb7 100755 --- a/test/types/symlink.rb +++ b/test/types/symlink.rb @@ -41,7 +41,7 @@ class TestSymlink < Test::Unit::TestCase unless hash.include?(:ensure) hash[:ensure] = mktmpfile() end - + link = Puppet.type(:symlink).create(hash) return link end diff --git a/test/types/type.rb b/test/types/type.rb index 0ca607695..b87ca2bd5 100644 --- a/test/types/type.rb +++ b/test/types/type.rb @@ -207,7 +207,7 @@ class TestType < Test::Unit::TestCase } assert_equal(path, file[:path]) - assert_equal([name], file[:alias]) + assert_equal(name, file.title) assert_nothing_raised { file.retrieve @@ -655,6 +655,36 @@ end assert_nil(obj.should(:type), "Type param passed through") end + + def test_multiplenames + obj = nil + path = tempfile() + assert_raise ArgumentError do + obj = Puppet::Type.type(:file).create( + :name => path, + :path => path + ) + end + end + + def test_title_and_name + obj = nil + path = tempfile() + fileobj = Puppet::Type.type(:file) + + assert_nothing_raised do + obj = fileobj.create( + :title => "myfile", + :path => path + ) + end + + assert_equal(obj, fileobj["myfile"], + "Could not retrieve obj by title") + + assert_equal(obj, fileobj[path], + "Could not retrieve obj by name") + end end # $Id$ |