diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/language/interpreter.rb | 12 | ||||
-rw-r--r-- | test/language/parser.rb | 1 | ||||
-rwxr-xr-x | test/language/rails.rb | 8 | ||||
-rwxr-xr-x | test/language/scope.rb | 88 | ||||
-rw-r--r-- | test/puppettest.rb | 1 |
5 files changed, 90 insertions, 20 deletions
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb index 509f004a4..8603e7f1c 100755 --- a/test/language/interpreter.rb +++ b/test/language/interpreter.rb @@ -86,8 +86,9 @@ class TestInterpreter < Test::Unit::TestCase assert_nothing_raised { interp = Puppet::Parser::Interpreter.new( :Manifest => file, - :UseNodes => false - ) + :UseNodes => false, + :ForkSave => false + ) } facts = {} @@ -102,13 +103,6 @@ class TestInterpreter < Test::Unit::TestCase assert(obj, "Could not find host object") end - if defined? ActiveRecord - def test_collectstorage - end - else - $stderr.puts "Install Rails for configuration storage testing" - end - if Facter["domain"].value == "madstop.com" begin require 'ldap' diff --git a/test/language/parser.rb b/test/language/parser.rb index 848f0128e..d82916eea 100644 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -304,6 +304,7 @@ class TestParser < Test::Unit::TestCase # Verify that collectable objects are marked that way. def test_collectable + Puppet[:storeconfigs] = true ["@port { ssh: protocols => tcp, number => 22 }", "@port { ssh: protocols => tcp, number => 22; smtp: protocols => tcp, number => 25 }"].each do |text| diff --git a/test/language/rails.rb b/test/language/rails.rb index 13bee4c5b..df76b4f20 100755 --- a/test/language/rails.rb +++ b/test/language/rails.rb @@ -97,14 +97,6 @@ class TestRails < Test::Unit::TestCase assert_equal(collectable.length, list.length, "Did not get the right number of objects") end - - def test_railsinit - assert_nothing_raised { - Puppet::Rails.init - } - - assert(FileTest.exists?(Puppet[:dblocation]), "Database does not exist") - end else $stderr.puts "Install Rails for Rails and Caching tests" end diff --git a/test/language/scope.rb b/test/language/scope.rb index aeac1f20b..c980e5055 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -714,9 +714,91 @@ class TestScope < Test::Unit::TestCase trans = scope.evaluate(:ast => top) } - trans.flatten.each do |obj| - assert(obj.collectable, "Object %s[%s] is not collectable" % - [obj.type, obj.name]) + %w{file}.each do |type| + objects = scope.exported(type) + + assert(!objects.empty?, "Did not get an exported %s" % type) end end + + # Verify that we can both store and collect an object in the same + # run. + def test_storeandcollect + Puppet[:storeconfigs] = true + Puppet::Rails.clear + Puppet::Rails.init + sleep 1 + children = [] + file = tempfile() + File.open(file, "w") { |f| + #f.puts "@file { \"#{file}\": mode => 644 } +#file <||>" + f.puts " +@host { puppet: ip => \"192.168.0.3\" } + +host <||>" + } + + interp = nil + assert_nothing_raised { + interp = Puppet::Parser::Interpreter.new( + :Manifest => file, + :UseNodes => false, + :ForkSave => false + ) + } + + 2.times { |i| + objects = nil + assert_nothing_raised { + objects = interp.run("localhost", {}) + } + } + end + + # Verify that we cannot override differently exported objects + def test_exportedoverrides + filename = tempfile() + children = [] + + 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() + ) + } + + top = nil + assert_nothing_raised("Could not create top object") { + top = AST::ASTArray.new( + :children => children + ) + } + + objects = nil + scope = nil + assert_raise(Puppet::ParseError, "Incorrectly allowed override") { + scope = Puppet::Parser::Scope.new() + objects = scope.evaluate(:ast => top) + } + end end diff --git a/test/puppettest.rb b/test/puppettest.rb index ed0383fd3..c509055d1 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -132,6 +132,7 @@ module TestPuppet @@tmppids.clear Puppet::Type.allclear Puppet::Storage.clear + Puppet::Rails.clear Puppet.clear @memoryatend = Puppet::Util.memory |