diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-28 03:32:51 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-28 03:32:51 +0000 |
| commit | 8b5f70911d7486a5cab69377c1988f1e35d88d2e (patch) | |
| tree | a8db890dbe5a28e679c86ca15e775eb77f6a0a59 /test/language | |
| parent | eda9d955b3fb2bbe5d7ca2cc3f7802d5fb9395ef (diff) | |
| download | puppet-8b5f70911d7486a5cab69377c1988f1e35d88d2e.tar.gz puppet-8b5f70911d7486a5cab69377c1988f1e35d88d2e.tar.xz puppet-8b5f70911d7486a5cab69377c1988f1e35d88d2e.zip | |
Fixing bug #60. Converting nodes to use types everywhere instead of names, and adding a localobjectable to keep track of what parameters have been defined locally.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@957 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/language')
| -rwxr-xr-x | test/language/ast.rb | 11 | ||||
| -rwxr-xr-x | test/language/scope.rb | 40 |
2 files changed, 42 insertions, 9 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb index 0c164b64a..441c7d892 100755 --- a/test/language/ast.rb +++ b/test/language/ast.rb @@ -58,7 +58,7 @@ class TestAST < Test::Unit::TestCase } assert_equal(1, scope.find_all { |child| - child.lookupobject("/parent", "file") + child.lookupobject(:name => "/parent", :type => "file") }.length, "Found incorrect number of '/parent' objects") end @@ -83,7 +83,7 @@ class TestAST < Test::Unit::TestCase obj = nil assert_nothing_raised("Could not retrieve file object") { - obj = scope.lookupobject("/etc", "file") + obj = scope.lookupobject(:name => "/etc", :type => "file") } assert(obj, "could not retrieve file object") @@ -172,9 +172,6 @@ class TestAST < Test::Unit::TestCase scope = nil assert_nothing_raised("Could not evaluate node") { scope = Puppet::Parser::Scope.new() - scope.type = "puppet" - scope.name = "top" - scope.top = true top.evaluate(:scope => scope) } @@ -192,6 +189,7 @@ class TestAST < Test::Unit::TestCase assert_nothing_raised("Could not retrieve node definition") { objects = scope.evalnode(:name => [nodename], :facts => {}) } + assert(objects, "Could not retrieve node definition") # Because node scopes are temporary (i.e., they get destroyed after the node's @@ -224,6 +222,9 @@ class TestAST < Test::Unit::TestCase assert(obj.path !~ /#{nodename}\[#{nodename}\]/, "Node name appears twice") } + + assert(Puppet::Type.type(:file)["/child1"], "Could not find child") + assert(Puppet::Type.type(:file)["/parent"], "Could not find parent") end # Test that you can look a host up using multiple names, e.g., an FQDN and diff --git a/test/language/scope.rb b/test/language/scope.rb index ee896ab32..2921afb42 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -277,7 +277,7 @@ class TestScope < Test::Unit::TestCase # verify we can set a host assert_nothing_raised("Could not create host") { child1.setnode("testing", AST::Node.new( - :name => "testing", + :type => "testing", :code => :notused ) ) @@ -286,7 +286,7 @@ class TestScope < Test::Unit::TestCase # Verify we cannot redefine it assert_raise(Puppet::ParseError, "Duplicate host creation succeeded") { child2.setnode("testing", AST::Node.new( - :name => "testing", + :type => "testing", :code => :notused ) ) @@ -356,6 +356,38 @@ class TestScope < Test::Unit::TestCase } 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() @@ -396,8 +428,8 @@ class TestScope < Test::Unit::TestCase scope = nil assert_nothing_raised("Could not evaluate") { scope = Puppet::Parser::Scope.new() - scope.name = "topscope" - scope.type = "topscope" + #scope.name = "topscope" + #scope.type = "topscope" objects = scope.evaluate(:ast => top) } |
