diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-23 01:12:26 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-23 01:12:26 +0000 |
| commit | 4c13c1053a9dcf14d9783bef288a7e98cda6fd9e (patch) | |
| tree | 167514ce266d81594c6e4419e46e87daaf667202 /test | |
| parent | 781c69b7d2c2a70b794d4fccb011c68e4d7a4950 (diff) | |
Nodes now support inheritance, for better or for worse.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@701 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/tc_ast.rb | 62 | ||||
| -rwxr-xr-x | test/language/tc_scope.rb | 4 |
2 files changed, 62 insertions, 4 deletions
diff --git a/test/language/tc_ast.rb b/test/language/tc_ast.rb index c8cd2f5d2..ab336c9e1 100755 --- a/test/language/tc_ast.rb +++ b/test/language/tc_ast.rb @@ -283,7 +283,7 @@ class TestAST < TestPuppet assert(! scope.lookupclass("parent"), "Found parent class in top scope") # verify we can find our node - assert(scope.findnode(nodename), "Could not find node") + assert(scope.node(nodename), "Could not find node") # And verify that we can evaluate it okay objects = nil @@ -399,7 +399,7 @@ class TestAST < TestPuppet end # Test that we can 'include' variables, not just normal strings. - def test_zincludevars + def test_includevars children = [] # Create our class for testin @@ -438,4 +438,62 @@ class TestAST < TestPuppet assert_equal("/%s" % klassname, objects[0][0][:name]) } end + + # Test that node inheritance works correctly + def test_nodeinheritance + children = [] + + # create the base node + name = "basenode" + children << nodeobj(name) + + # and the sub node + name = "subnode" + children << AST::NodeDef.new( + :names => nameobj(name), + :parentclass => nameobj("basenode"), + :code => AST::ASTArray.new( + :children => [ + varobj("%svar" % name, "%svalue" % name), + fileobj("/%s" % name) + ] + ) + ) + #subnode = nodeobj(name) + #subnode.parentclass = "basenode" + + #children << subnode + + # and the top object + top = nil + assert_nothing_raised("Could not create top object") { + top = AST::ASTArray.new( + :children => children + ) + } + + # Evaluate the parse tree + scope = nil + assert_nothing_raised("Could not evaluate node") { + scope = Puppet::Parser::Scope.new() + top.evaluate(scope) + } + + # Verify we can find the node via a search list + objects = nil + assert_nothing_raised("Could not retrieve node definition") { + objects = scope.evalnode([name], {}) + } + assert(objects, "Could not retrieve node definition") + + # And now verify that we got the subnode file + assert_nothing_raised("Could not find basenode file") { + assert_equal("/basenode", objects[0][0][:name]) + } + + # and the parent node file + assert_nothing_raised("Could not find subnode file") { + assert_equal("/subnode", objects[0][1][:name]) + } + end end diff --git a/test/language/tc_scope.rb b/test/language/tc_scope.rb index 192b74b61..5b1918707 100755 --- a/test/language/tc_scope.rb +++ b/test/language/tc_scope.rb @@ -294,8 +294,8 @@ class TestScope < TestPuppet # Now verify we can find the host again host = nil assert_nothing_raised("Host lookup failed") { - scope = top.findnode("testing") - host = scope.node("testing") + hash = top.node("testing") + host = hash[:node] } assert(host, "Could not find host") |
