diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-04 18:24:24 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-04 18:24:24 +0000 |
| commit | 28cee40689440388994a4768bd301ae32c8ecc05 (patch) | |
| tree | c865ab44f4c9247052cf83de16ffc8ebe8b15e54 /test/language/scope.rb | |
| parent | e0e291332bd4676962a28c7b220ae5c5e9651c0a (diff) | |
| download | puppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.gz puppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.xz puppet-28cee40689440388994a4768bd301ae32c8ecc05.zip | |
Merging the changes from the override-refactor branch. This is a significant rewrite of the parser, but it has little affect on the rest of the code tree.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1726 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/language/scope.rb')
| -rwxr-xr-x | test/language/scope.rb | 760 |
1 files changed, 218 insertions, 542 deletions
diff --git a/test/language/scope.rb b/test/language/scope.rb index 85189627d..b9401e38b 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -5,6 +5,8 @@ require 'puppet/parser/interpreter' require 'puppet/parser/parser' require 'puppet/client' require 'puppettest' +require 'puppettest/parsertesting' +require 'puppettest/resourcetesting' # so, what kind of things do we want to test? @@ -17,6 +19,7 @@ require 'puppettest' class TestScope < Test::Unit::TestCase include PuppetTest::ParserTesting + include PuppetTest::ResourceTesting def to_ary(hash) hash.collect { |key,value| @@ -35,7 +38,7 @@ class TestScope < Test::Unit::TestCase 10.times { |index| # slap some recursion in there - scope = Puppet::Parser::Scope.new(:parent => scope) + scope = mkscope(:parent => scope) scopes.push scope var = "var%s" % index @@ -97,8 +100,8 @@ class TestScope < Test::Unit::TestCase def test_declarative # set to declarative - top = Puppet::Parser::Scope.new(:declarative => true) - sub = Puppet::Parser::Scope.new(:parent => top) + top = mkscope(:declarative => true) + sub = mkscope(:parent => top) assert_nothing_raised { top.setvar("test","value") @@ -116,8 +119,8 @@ class TestScope < Test::Unit::TestCase def test_notdeclarative # set to not declarative - top = Puppet::Parser::Scope.new(:declarative => false) - sub = Puppet::Parser::Scope.new(:parent => top) + top = mkscope(:declarative => false) + sub = mkscope(:parent => top) assert_nothing_raised { top.setvar("test","value") @@ -133,106 +136,65 @@ class TestScope < Test::Unit::TestCase } end - def test_defaults - scope = nil - over = "over" - - scopes = [] - vars = [] - values = {} - ovalues = [] + def test_setdefaults + interp, scope, source = mkclassframing - defs = Hash.new { |hash,key| - hash[key] = Hash.new(nil) - } - - prevdefs = Hash.new { |hash,key| - hash[key] = Hash.new(nil) - } - - params = %w{a list of parameters that could be used for defaults} + # The setdefaults method doesn't really check what we're doing, + # so we're just going to use fake defaults here. - types = %w{a set of types that could be used to set defaults} + # First do a simple local lookup + params = paramify(source, :one => "fun", :two => "shoe") + origshould = {} + params.each do |p| origshould[p.name] = p end + assert_nothing_raised do + scope.setdefaults(:file, params) + end - 10.times { |index| - scope = Puppet::Parser::Scope.new(:parent => scope) - scopes.push scope + ret = nil + assert_nothing_raised do + ret = scope.lookupdefaults(:file) + end - tmptypes = [] - - # randomly create defaults for a random set of types - tnum = rand(5) - tnum.times { |t| - # pick a type - #Puppet.debug "Type length is %s" % types.length - #s = rand(types.length) - #Puppet.debug "Type num is %s" % s - #type = types[s] - #Puppet.debug "Type is %s" % s - type = types[rand(types.length)] - if tmptypes.include?(type) - Puppet.debug "Duplicate type %s" % type - redo - else - tmptypes.push type - end + assert_equal(origshould, ret) - Puppet.debug "type is %s" % type + # Now create a subscope and add some more params. + newscope = scope.newscope - d = {} + newparams = paramify(source, :one => "shun", :three => "free") + assert_nothing_raised { + newscope.setdefaults(:file, newparams) + } - # randomly assign some parameters - num = rand(4) - num.times { |n| - param = params[rand(params.length)] - if d.include?(param) - Puppet.debug "Duplicate param %s" % param - redo - else - d[param] = rand(1000) - end - } + # And make sure we get the appropriate ones back + should = {} + params.each do |p| should[p.name] = p end + newparams.each do |p| should[p.name] = p end - # and then add a consistent type - d["always"] = rand(1000) + assert_nothing_raised do + ret = newscope.lookupdefaults(:file) + end - d.each { |var,val| - defs[type][var] = val - } + assert_equal(should, ret) - assert_nothing_raised { - scope.setdefaults(type,to_ary(d)) - } - fdefs = nil - assert_nothing_raised { - fdefs = scope.lookupdefaults(type) - } + # Make sure we still only get the originals from the top scope + assert_nothing_raised do + ret = scope.lookupdefaults(:file) + end - # now, make sure that reassignment fails if we're - # in declarative mode - assert_raise(Puppet::ParseError) { - scope.setdefaults(type,[%w{always funtest}]) - } + assert_equal(origshould, ret) - # assert that we have collected the same values - assert_equal(defs[type],fdefs) + # Now create another scope and make sure we only get the top defaults + otherscope = scope.newscope + assert_equal(origshould, otherscope.lookupdefaults(:file)) - # now assert that our parent still finds the same defaults - # it got last time - if parent = scope.parent - unless prevdefs[type].nil? - assert_equal(prevdefs[type],parent.lookupdefaults(type)) - end - end - d.each { |var,val| - prevdefs[type][var] = val - } - } - } + # And make sure none of the scopes has defaults for other types + [scope, newscope, otherscope].each do |sc| + assert_equal({}, sc.lookupdefaults(:exec)) + end end def test_strinterp - scope = Puppet::Parser::Scope.new() + scope = mkscope() assert_nothing_raised { scope.setvar("test","value") @@ -264,313 +226,61 @@ class TestScope < Test::Unit::TestCase assert_equal("$test string", val) end - # Test some of the host manipulations - def test_hostlookup - top = Puppet::Parser::Scope.new() - - # Create a deep scope tree, so that we know we're doing a deeply recursive - # search. - mid1 = Puppet::Parser::Scope.new(:parent => top) - mid2 = Puppet::Parser::Scope.new(:parent => mid1) - mid3 = Puppet::Parser::Scope.new(:parent => mid2) - child1 = Puppet::Parser::Scope.new(:parent => mid3) - mida = Puppet::Parser::Scope.new(:parent => top) - midb = Puppet::Parser::Scope.new(:parent => mida) - midc = Puppet::Parser::Scope.new(:parent => midb) - child2 = Puppet::Parser::Scope.new(:parent => midc) - - # verify we can set a host - assert_nothing_raised("Could not create host") { - child1.setnode("testing", AST::Node.new( - :type => "testing", - :code => :notused - ) - ) - } - - # Verify we cannot redefine it - assert_raise(Puppet::ParseError, "Duplicate host creation succeeded") { - child2.setnode("testing", AST::Node.new( - :type => "testing", - :code => :notused - ) - ) - } - - # Now verify we can find the host again - host = nil - assert_nothing_raised("Host lookup failed") { - hash = top.node("testing") - host = hash[:node] - } - - assert(host, "Could not find host") - assert(host.code == :notused, "Host is not what we stored") - end - - # Verify that two statements about a file within the same scope tree - # will cause a conflict. - def test_noconflicts - filename = tempfile() - children = [] - - # create the parent class - children << classobj("one", :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => "root") - ] - )) - - # now create a child class with differ values - children << classobj("two", - :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => "bin") - ] - )) - - # Now call the child class - assert_nothing_raised("Could not add AST nodes for calling") { - children << AST::ObjectDef.new( - :type => nameobj("two"), - :name => nameobj("yayness"), - :params => astarray() - ) << AST::ObjectDef.new( - :type => nameobj("one"), - :name => nameobj("yayness"), - :params => astarray() - ) - } - - top = nil - assert_nothing_raised("Could not create top object") { - top = AST::ASTArray.new( - :children => children - ) - } - - objects = nil - scope = nil - - # Here's where we should encounter the failure. It should find that - # it has already created an object with that name, and this should result - # in some pukey-pukeyness. - assert_raise(Puppet::ParseError) { - scope = Puppet::Parser::Scope.new() - objects = scope.evaluate(:ast => top) - } - end - - # Verify that statements about the same element within the same scope - # cause a conflict. - def test_failonconflictinsamescope - filename = tempfile() - children = [] - - # Now call the child class - assert_nothing_raised("Could not add AST nodes for calling") { - children << fileobj(filename, "owner" => "root") - children << fileobj(filename, "owner" => "bin") - } - - top = nil - assert_nothing_raised("Could not create top object") { - top = AST::ASTArray.new( - :children => children - ) - } - - objects = nil - scope = nil - - # Here's where we should encounter the failure. It should find that - # it has already created an object with that name, and this should result - # in some pukey-pukeyness. - assert_raise(Puppet::ParseError) { - scope = Puppet::Parser::Scope.new() - scope.top = true - objects = scope.evaluate(:ast => top) - } - end - - # Verify that we override statements that we find within our scope - def test_suboverrides - filename = tempfile() - children = [] - - # create the parent class - children << classobj("parent", :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => "root") - ] - )) - - # now create a child class with differ values - children << classobj("child", :parentclass => nameobj("parent"), - :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => "bin") - ] - )) - - # Now call the child class - assert_nothing_raised("Could not add AST nodes for calling") { - children << AST::ObjectDef.new( - :type => nameobj("child"), - :name => nameobj("yayness"), - :params => astarray() - ) - } - - top = nil - assert_nothing_raised("Could not create top object") { - top = AST::ASTArray.new( - :children => children - ) - } - - objects = nil - scope = nil - assert_nothing_raised("Could not evaluate") { - scope = Puppet::Parser::Scope.new() - objects = scope.evaluate(:ast => top) - } - - assert_equal(1, objects.length, "Returned too many objects: %s" % - objects.inspect) - - assert_equal(1, objects[0].length, "Returned too many objects: %s" % - objects[0].inspect) - - assert_nothing_raised { - file = objects[0][0] - assert_equal("bin", file["owner"], "Value did not override correctly") - } - end - - def test_multipletypes - scope = Puppet::Parser::Scope.new() - children = [] - - # create the parent class - children << classobj("aclass") - children << classobj("aclass") - top = nil - assert_nothing_raised("Could not create top object") { - top = AST::ASTArray.new( - :children => children - ) - } - - scope = nil - assert_raise(Puppet::ParseError) { - scope = Puppet::Parser::Scope.new() - objects = top.evaluate(:scope => scope) - } - end - - # Verify that definitions have a different context than classes. - def test_newsubcontext - filename = tempfile() - children = [] - - # Create a component - children << compobj("comp", :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => "root" ) - ] - )) - - # Now create a class that modifies the same file and also - # calls the component - children << classobj("klass", :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => "bin" ), - AST::ObjectDef.new( - :type => nameobj("comp"), - :params => astarray() - ) - ] - )) - - # Now call the class - children << AST::ObjectDef.new( - :type => nameobj("klass"), - :params => astarray() - ) - - top = nil - assert_nothing_raised("Could not create top object") { - top = AST::ASTArray.new( - :children => children - ) - } + def test_setclass + interp, scope, source = mkclassframing - trans = nil - scope = nil - #assert_nothing_raised { - assert_raise(Puppet::ParseError, "A conflict was allowed") { - scope = Puppet::Parser::Scope.new() - trans = scope.evaluate(:ast => top) - } - # scope = Puppet::Parser::Scope.new() - # trans = scope.evaluate(:ast => top) - #} - end + base = scope.findclass("base") + assert(base, "Could not find base class") + assert(! scope.setclass?(base), "Class incorrectly set") + assert(! scope.classlist.include?("base"), "Class incorrectly in classlist") + assert_nothing_raised do + scope.setclass base + end - def test_defaultswithmultiplestatements - path = tempfile() + assert(scope.setclass?(base), "Class incorrectly unset") + assert(scope.classlist.include?("base"), "Class not in classlist") - stats = [] - stats << defaultobj("file", "group" => "root") - stats << fileobj(path, "owner" => "root") - stats << fileobj(path, "mode" => "755") + # Now try it with a normal string + assert_raise(Puppet::DevError) do + scope.setclass "string" + end - top = AST::ASTArray.new( - :file => __FILE__, - :line => __LINE__, - :children => stats - ) - scope = Puppet::Parser::Scope.new() - trans = nil - assert_nothing_raised { - trans = scope.evaluate(:ast => top) - } + assert(! scope.setclass?("string"), "string incorrectly set") - obj = trans.find do |obj| obj.is_a? Puppet::TransObject end + # Set "" in the class list, and make sure it doesn't show up in the return + top = scope.findclass("") + assert(top, "Could not find top class") + scope.setclass top - assert(obj, "Could not retrieve file obj") - assert_equal("root", obj["group"], "Default did not take") - assert_equal("root", obj["owner"], "Owner did not take") - assert_equal("755", obj["mode"], "Mode did not take") + assert(! scope.classlist.include?(""), "Class list included empty") end - def test_validclassnames - scope = Puppet::Parser::Scope.new() + def test_validtags + scope = mkscope() - ["a class", "Class", "a.class"].each do |bad| + ["a class", "a.class"].each do |bad| assert_raise(Puppet::ParseError, "Incorrectly allowed %s" % bad.inspect) do - scope.setclass(object_id, bad) + scope.tag(bad) end end - ["a-class", "a_class", "class", "yayNess"].each do |good| + ["a-class", "a_class", "Class", "class", "yayNess"].each do |good| assert_nothing_raised("Incorrectly banned %s" % good.inspect) do - scope.setclass(object_id, good) + scope.tag(good) end end end def test_tagfunction - scope = Puppet::Parser::Scope.new() + scope = mkscope() assert_nothing_raised { scope.function_tag(["yayness", "booness"]) } - assert(scope.classlist.include?("yayness"), "tag 'yayness' did not get set") - assert(scope.classlist.include?("booness"), "tag 'booness' did not get set") + assert(scope.tags.include?("yayness"), "tag 'yayness' did not get set") + assert(scope.tags.include?("booness"), "tag 'booness' did not get set") # Now verify that the 'tagged' function works correctly assert(scope.function_tagged("yayness"), @@ -583,77 +293,37 @@ class TestScope < Test::Unit::TestCase end def test_includefunction - scope = Puppet::Parser::Scope.new() - - one = tempfile() - two = tempfile() - - children = [] - - children << classobj("one", :code => AST::ASTArray.new( - :children => [ - fileobj(one, "owner" => "root") - ] - )) + interp = mkinterp + scope = mkscope :interp => interp - children << classobj("two", :code => AST::ASTArray.new( - :children => [ - fileobj(two, "owner" => "root") - ] - )) + myclass = interp.newclass "myclass" + otherclass = interp.newclass "otherclass" - children << Puppet::Parser::AST::Function.new( + function = Puppet::Parser::AST::Function.new( :name => "include", :ftype => :statement, :arguments => AST::ASTArray.new( - :children => [nameobj("one"), nameobj("two")] + :children => [nameobj("myclass"), nameobj("otherclass")] ) ) - top = AST::ASTArray.new(:children => children) - - #assert_nothing_raised { - # scope.function_include(["one", "two"]) - #} - - assert_nothing_raised { - scope.evaluate(:ast => top) - } - - - assert(scope.classlist.include?("one"), "tag 'one' did not get set") - assert(scope.classlist.include?("two"), "tag 'two' did not get set") + assert_nothing_raised do + function.evaluate :scope => scope + end - # Now verify that the 'tagged' function works correctly - assert(scope.function_tagged("one"), - "tagged function incorrectly returned false") - assert(scope.function_tagged("two"), - "tagged function incorrectly returned false") + [myclass, otherclass].each do |klass| + assert(scope.setclass?(klass), + "%s was not set" % klass.fqname) + end end def test_definedfunction - scope = Puppet::Parser::Scope.new() - - one = tempfile() - two = tempfile() - - children = [] - - children << classobj("one", :code => AST::ASTArray.new( - :children => [ - fileobj(one, "owner" => "root") - ] - )) - - children << classobj("two", :code => AST::ASTArray.new( - :children => [ - fileobj(two, "owner" => "root") - ] - )) - - top = AST::ASTArray.new(:children => children) + interp = mkinterp + %w{one two}.each do |name| + interp.newdefine name + end - top.evaluate(:scope => scope) + scope = mkscope :interp => interp assert_nothing_raised { %w{one two file user}.each do |type| @@ -664,40 +334,6 @@ class TestScope < Test::Unit::TestCase assert(!scope.function_defined(["nopeness"]), "Class 'nopeness' was incorrectly considered defined") } - - - end - - # Make sure components acquire defaults. - def test_defaultswithcomponents - children = [] - - # Create a component - filename = tempfile() - args = AST::ASTArray.new( - :file => tempfile(), - :line => rand(100), - :children => [nameobj("argument")] - ) - children << compobj("comp", :args => args, :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => varref("argument") ) - ] - )) - - # Create a default - children << defaultobj("comp", "argument" => "yayness") - - # lastly, create an object that calls our third component - children << objectdef("comp", "boo", {"argument" => "parentfoo"}) - - trans = assert_evaluate(children) - - flat = trans.flatten - - assert(!flat.empty?, "Got no objects back") - - assert_equal("parentfoo", flat[0]["owner"], "default did not take") end # Make sure we know what we consider to be truth. @@ -714,7 +350,7 @@ class TestScope < Test::Unit::TestCase # Verify scope context is handled correctly. def test_scopeinside - scope = Puppet::Parser::Scope.new() + scope = mkscope() one = :one two = :two @@ -763,9 +399,10 @@ class TestScope < Test::Unit::TestCase end if defined? ActiveRecord - # Verify that we recursively mark as collectable the results of collectable + # Verify that we recursively mark as exported the results of collectable # components. - def test_collectablecomponents + def test_exportedcomponents + interp, scope, source = mkclassframing children = [] args = AST::ASTArray.new( @@ -773,47 +410,44 @@ class TestScope < Test::Unit::TestCase :line => rand(100), :children => [nameobj("arg")] ) + # Create a top-level component - children << compobj("one", :args => args) + interp.newdefine "one", :arguments => [%w{arg}], + :code => AST::ASTArray.new( + :children => [ + resourcedef("file", "/tmp", {"owner" => varref("arg")}) + ] + ) # And a component that calls it - children << compobj("two", :args => args, :code => AST::ASTArray.new( - :children => [ - objectdef("one", "ptest", {"arg" => "parentfoo"}) - ] - )) + interp.newdefine "two", :arguments => [%w{arg}], + :code => AST::ASTArray.new( + :children => [ + resourcedef("one", "ptest", {"arg" => varref("arg")}) + ] + ) # And then a third component that calls the second - children << compobj("three", :args => args, :code => AST::ASTArray.new( - :children => [ - objectdef("two", "yay", {"arg" => "parentfoo"}) - ] - )) + interp.newdefine "three", :arguments => [%w{arg}], + :code => AST::ASTArray.new( + :children => [ + resourcedef("two", "yay", {"arg" => varref("arg")}) + ] + ) # lastly, create an object that calls our third component - obj = objectdef("three", "boo", {"arg" => "parentfoo"}) - - # And mark it as collectable - obj.collectable = true + obj = resourcedef("three", "boo", {"arg" => "parentfoo"}) - children << obj + # And mark it as exported + obj.exported = true - top = nil - assert_nothing_raised("Could not create top object") { - top = AST::ASTArray.new( - :children => children - ) - } + obj.evaluate :scope => scope - trans = nil - scope = nil - assert_nothing_raised { - scope = Puppet::Parser::Scope.new() - trans = scope.evaluate(:ast => top) - } + # And then evaluate it + interp.evaliterate(scope) %w{file}.each do |type| - objects = scope.exported(type) + objects = scope.lookupexported(type) assert(!objects.empty?, "Did not get an exported %s" % type) end @@ -832,11 +466,11 @@ class TestScope < Test::Unit::TestCase File.open(file, "w") { |f| f.puts " class yay { - @host { myhost: ip => \"192.168.0.2\" } + @@host { myhost: ip => \"192.168.0.2\" } } include yay -@host { puppet: ip => \"192.168.0.3\" } -host <||>" +@@host { puppet: ip => \"192.168.0.3\" } +Host <<||>>" } interp = nil @@ -853,7 +487,7 @@ host <||>" # if we pull it up from the database. 2.times { |i| assert_nothing_raised { - objects = interp.run("localhost", {}) + objects = interp.run("localhost", {"hostname" => "localhost"}) } flat = objects.flatten @@ -863,53 +497,95 @@ host <||>" end } end + else + $stderr.puts "No ActiveRecord -- skipping collection tests" + end - # Verify that we cannot override differently exported objects - def test_exportedoverrides - filename = tempfile() - children = [] + # Make sure tags behave appropriately. + def test_tags + interp, scope, source = mkclassframing - obj = fileobj(filename, "owner" => "root") - obj.collectable = true - # create the parent class - children << classobj("parent", :code => AST::ASTArray.new( - :children => [ - obj - ] - )) - - # now create a child class with differ values - children << classobj("child", :parentclass => nameobj("parent"), - :code => AST::ASTArray.new( - :children => [ - fileobj(filename, "owner" => "bin") - ] - )) - - # Now call the child class - assert_nothing_raised("Could not add AST nodes for calling") { - children << AST::ObjectDef.new( - :type => nameobj("child"), - :name => nameobj("yayness"), - :params => astarray() - ) - } + # First make sure we can only set legal tags + ["an invalid tag", "-anotherinvalid", "bad*tag"].each do |tag| + assert_raise(Puppet::ParseError, "Tag #{tag} was considered valid") do + scope.tag tag + end + end - top = nil - assert_nothing_raised("Could not create top object") { - top = AST::ASTArray.new( - :children => children - ) - } + # Now make sure good tags make it through. + tags = %w{good-tag yaytag GoodTag another_tag} + tags.each do |tag| + assert_nothing_raised("Tag #{tag} was considered invalid") do + scope.tag tag + end + end - objects = nil - scope = nil - assert_raise(Puppet::ParseError, "Incorrectly allowed override") { - scope = Puppet::Parser::Scope.new() - objects = scope.evaluate(:ast => top) - } + # And make sure we get each of them. + ptags = scope.tags + tags.each do |tag| + assert(ptags.include?(tag), "missing #{tag}") + end + + + # Now create a subscope and set some tags there + newscope = scope.newscope(:type => 'subscope') + + # set some tags + newscope.tag "onemore", "yaytag" + + # And make sure we get them plus our parent tags + assert_equal((ptags + %w{onemore subscope}).sort, newscope.tags.sort) end - else - $stderr.puts "No ActiveRecord -- skipping collection tests" + + # Make sure we successfully translate objects + def test_translate + interp, scope, source = mkclassframing + + # Create a define that we'll be using + interp.newdefine("wrapper", :code => AST::ASTArray.new(:children => [ + resourcedef("file", varref("name"), "owner" => "root") + ])) + + # Now create a resource that uses that define + define = mkresource(:type => "wrapper", :title => "/tmp/testing", + :scope => scope, :source => source, :params => :none) + + scope.setresource define + + # And a normal resource + scope.setresource mkresource(:type => "file", :title => "/tmp/rahness", + :scope => scope, :source => source, + :params => {:owner => "root"}) + + # Evaluate the the define thing. + define.evaluate + + # Now the scope should have a resource and a subscope. Translate the + # whole thing. + ret = nil + assert_nothing_raised do + ret = scope.translate + end + + assert_instance_of(Puppet::TransBucket, ret) + + ret.each do |obj| + assert(obj.is_a?(Puppet::TransBucket) || obj.is_a?(Puppet::TransObject), + "Got a non-transportable object %s" % obj.class) + end + + rahness = ret.find { |c| c.type == "file" and c.name == "/tmp/rahness" } + assert(rahness, "Could not find top-level file") + assert_equal("root", rahness["owner"]) + + bucket = ret.find { |c| c.class == Puppet::TransBucket and c.name == "/tmp/testing" } + assert(bucket, "Could not find define bucket") + + testing = bucket.find { |c| c.type == "file" and c.name == "/tmp/testing" } + assert(testing, "Could not find define file") + assert_equal("root", testing["owner"]) + end end + +# $Id$ |
