diff options
| author | Dominic Maraglia <dominic@puppetlabs.com> | 2011-08-03 15:43:20 -0700 |
|---|---|---|
| committer | Dominic Maraglia <dominic@puppetlabs.com> | 2011-08-03 15:43:20 -0700 |
| commit | e45f08bf1fef8842554ca0d8cb6fb13711e888e7 (patch) | |
| tree | 9bb476a0fe381d53060abc1f1c240cf1291b2ee4 /test | |
| parent | a97c86e7d01384aa06f5d4d69da427fc355aebe7 (diff) | |
| parent | c833fde370d43023f52c8f2e11fd77e720d0f577 (diff) | |
| download | puppet-e45f08bf1fef8842554ca0d8cb6fb13711e888e7.tar.gz puppet-e45f08bf1fef8842554ca0d8cb6fb13711e888e7.tar.xz puppet-e45f08bf1fef8842554ca0d8cb6fb13711e888e7.zip | |
Merge branch 'master' of github.com:puppetlabs/puppet
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/ast/variable.rb | 29 | ||||
| -rwxr-xr-x | test/language/functions.rb | 24 | ||||
| -rwxr-xr-x | test/language/scope.rb | 30 | ||||
| -rwxr-xr-x | test/lib/puppettest.rb | 1 | ||||
| -rwxr-xr-x | test/network/handler/master.rb | 5 | ||||
| -rwxr-xr-x | test/network/server/webrick.rb | 27 | ||||
| -rwxr-xr-x | test/ral/type/filesources.rb | 1 |
7 files changed, 32 insertions, 85 deletions
diff --git a/test/language/ast/variable.rb b/test/language/ast/variable.rb deleted file mode 100755 index 968d1b7c3..000000000 --- a/test/language/ast/variable.rb +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2007-0419. -# Copyright (c) 2006. All rights reserved. - -require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest') - -require 'puppettest' -require 'puppettest/parsertesting' - -class TestVariable < Test::Unit::TestCase - include PuppetTest - include PuppetTest::ParserTesting - AST = Puppet::Parser::AST - - def setup - super - @scope = mkscope - @name = "myvar" - @var = AST::Variable.new(:value => @name) - end - - def test_evaluate - assert_equal(:undef, @var.evaluate(@scope), "did not return :undef on unset var") - @scope.setvar(@name, "something") - assert_equal("something", @var.evaluate(@scope), "incorrect variable value") - end -end - diff --git a/test/language/functions.rb b/test/language/functions.rb index 84b1b3861..44d86f0f9 100755 --- a/test/language/functions.rb +++ b/test/language/functions.rb @@ -148,17 +148,17 @@ class TestLangFunctions < Test::Unit::TestCase # Test that our use of an undefined instance variable does not throw # an exception, but only safely continues. - scope.setvar("one", "One") + scope['one'] = "One" assert_nothing_raised do ast.evaluate(scope) end # Ensure that we got the output we expected from that evaluation. - assert_equal("template One\ntemplate \n", scope.lookupvar("output"), "Undefined template variables do not raise exceptions") + assert_equal("template One\ntemplate \n", scope['output'], "Undefined template variables do not raise exceptions") # Now, fill in the last variable and make sure the whole thing # evaluates correctly. - scope.setvar("two", "Two") + scope['two'] = "Two" scope.unsetvar("output") assert_nothing_raised do ast.evaluate(scope) @@ -166,7 +166,7 @@ class TestLangFunctions < Test::Unit::TestCase assert_equal( - "template One\ntemplate Two\n", scope.lookupvar("output"), + "template One\ntemplate Two\n", scope['output'], "Templates were not handled correctly") end @@ -199,7 +199,7 @@ class TestLangFunctions < Test::Unit::TestCase ast.evaluate(scope) end - scope.setvar("yay", "this is yay") + scope['yay'] = "this is yay" assert_nothing_raised do ast.evaluate(scope) @@ -207,7 +207,7 @@ class TestLangFunctions < Test::Unit::TestCase assert_equal( - "template this is yay\n", scope.lookupvar("output"), + "template this is yay\n", scope['output'], "Templates were not handled correctly") @@ -243,14 +243,14 @@ class TestLangFunctions < Test::Unit::TestCase end # Verify that we evaluate and return their value correctly. - scope.setvar("deprecated", "deprecated value") + scope["deprecated"] = "deprecated value" assert_nothing_raised do ast.evaluate(scope) end assert_equal( - "template deprecated value\n", scope.lookupvar("output"), + "template deprecated value\n", scope['output'], "Deprecated template variables were not handled correctly") end @@ -305,7 +305,7 @@ class TestLangFunctions < Test::Unit::TestCase ast = varobj("output", func) scope = mkscope - scope.setvar("myvar", "this is yayness") + scope['myvar'] = "this is yayness" assert_raise(Puppet::ParseError) do ast.evaluate(scope) end @@ -381,15 +381,15 @@ class TestLangFunctions < Test::Unit::TestCase false => "false", }.each do |string, value| scope = mkscope - scope.setvar("yayness", string) - assert_equal(string, scope.lookupvar("yayness")) + scope['yayness'] = string + assert_equal(scope['yayness'], string, "did not correctly evaluate '#{string}'") assert_nothing_raised("An empty string was not a valid variable value") do ast.evaluate(scope) end assert_equal( - "template #{value}\n", scope.lookupvar("output"), + "template #{value}\n", scope['output'], "#{string.inspect} did not get evaluated correctly") end end diff --git a/test/language/scope.rb b/test/language/scope.rb index ccc359651..c80178e7b 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -40,24 +40,24 @@ class TestScope < Test::Unit::TestCase scopes = {:top => topscope, :mid => midscope, :bot => botscope} # Set a variable in the top and make sure all three can get it - topscope.setvar("first", "topval") + topscope['first'] = 'topval' scopes.each do |name, scope| - assert_equal("topval", scope.lookupvar("first"), "Could not find var in #{name}") + assert_equal("topval", scope['first'], "Could not find var in #{name}") end # Now set a var in the midscope and make sure the mid and bottom can see it but not the top - midscope.setvar("second", "midval") - assert_equal(:undefined, scopes[:top].lookupvar("second"), "Found child var in top scope") + midscope['second'] = "midval" + assert_nil(scopes[:top]['second'], "Found child var in top scope") [:mid, :bot].each do |name| - assert_equal("midval", scopes[name].lookupvar("second"), "Could not find var in #{name}") + assert_equal("midval", scopes[name]['second'], "Could not find var in #{name}") end # And set something in the bottom, and make sure we only find it there. - botscope.setvar("third", "botval") + botscope['third'] = "botval" [:top, :mid].each do |name| - assert_equal(:undefined, scopes[name].lookupvar("third"), "Found child var in top scope") + assert_nil(scopes[name]['third'], "Found child var in top scope") end - assert_equal("botval", scopes[:bot].lookupvar("third"), "Could not find var in bottom scope") + assert_equal("botval", scopes[:bot]['third'], "Could not find var in bottom scope") # Test that the scopes convert to hash structures correctly. @@ -84,7 +84,7 @@ class TestScope < Test::Unit::TestCase # Finally, check the ability to shadow symbols by adding a shadow to # bottomscope, then checking that we see the right stuff. - botscope.setvar("first", "shadowval") + botscope['first'] = "shadowval" assert_equal( {"third" => "botval", "first" => "shadowval"}, @@ -105,16 +105,16 @@ class TestScope < Test::Unit::TestCase sub = mkscope(:parent => top) assert_nothing_raised { - top.setvar("test","value") + top['test'] = "value" } assert_raise(Puppet::ParseError) { - top.setvar("test","other") + top['test'] = 'other' } assert_nothing_raised { - sub.setvar("test","later") + top['other'] = 'later' } assert_raise(Puppet::ParseError) { - top.setvar("test","yeehaw") + top['other'] = 'yeehaw' } end @@ -259,8 +259,8 @@ Host <<||>>" def test_lookupvar_with_undef scope = mkscope - scope.setvar("testing", :undef) - assert_equal(:undef, scope.lookupvar("testing"), "undef was not returned as :undef") + scope['testing'] = :undef + assert_equal(:undef, scope['testing'], "undef was not returned as :undef") end end diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index a60092cf7..6bae80a01 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -280,7 +280,6 @@ module PuppetTest Puppet::Util::Storage.clear Puppet.clear Puppet.settings.clear - Puppet::Util::Cacher.expire @memoryatend = Puppet::Util.memory diff = @memoryatend - @memoryatstart diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index 4c0374a76..9326e4b38 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -16,11 +16,6 @@ class TestMaster < Test::Unit::TestCase Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog) end - def teardown - super - Puppet::Util::Cacher.expire - end - def test_freshness_is_always_now now1 = mock 'now1' Time.stubs(:now).returns(now1) diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb index 624147b6c..e1fd68921 100755 --- a/test/network/server/webrick.rb +++ b/test/network/server/webrick.rb @@ -11,24 +11,17 @@ class TestWebrickServer < Test::Unit::TestCase def setup Puppet::Util::SUIDManager.stubs(:asuser).yields + Puppet::SSL::Host.instance_variable_set(:@localhost, nil) super end - def teardown - super - Puppet::Network::HttpPool.clear_http_instances - end - # Make sure we can create a server, and that it knows how to create its # certs by default. def test_basics server = nil assert_raise(Puppet::Error, "server succeeded with no cert") do - - server = Puppet::Network::HTTPServer::WEBrick.new( - + server = Puppet::Network::HTTPServer::WEBrick.new( :Port => @@port, - :Handlers => { :Status => nil } @@ -36,11 +29,8 @@ class TestWebrickServer < Test::Unit::TestCase end assert_nothing_raised("Could not create simple server") do - - server = Puppet::Network::HTTPServer::WEBrick.new( - + server = Puppet::Network::HTTPServer::WEBrick.new( :Port => @@port, - :Handlers => { :CA => {}, # so that certs autogenerate :Status => nil @@ -76,11 +66,8 @@ class TestWebrickServer < Test::Unit::TestCase client = nil assert_nothing_raised { - - client = Puppet::Network::Client.status.new( - + client = Puppet::Network::Client.status.new( :Server => "localhost", - :Port => @@port ) } @@ -91,17 +78,13 @@ class TestWebrickServer < Test::Unit::TestCase server = nil Puppet[:certdnsnames] = "localhost" assert_nothing_raised { - - server = Puppet::Network::HTTPServer::WEBrick.new( - + server = Puppet::Network::HTTPServer::WEBrick.new( :Port => @@port, - :Handlers => { :CA => {}, # so that certs autogenerate :Status => nil } ) - } pid = fork { diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb index 3363aafb3..f39d53907 100755 --- a/test/ral/type/filesources.rb +++ b/test/ral/type/filesources.rb @@ -26,7 +26,6 @@ class TestFileSources < Test::Unit::TestCase def teardown super - Puppet::Network::HttpPool.clear_http_instances end def use_storage |
