diff options
author | Luke Kanies <luke@madstop.com> | 2008-01-14 13:34:06 -0800 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-01-14 13:34:06 -0800 |
commit | cfda651f88d12249f29706d2bedbfddce7a2e6f7 (patch) | |
tree | 41c57e5e1405691a561b35b1ceac890c6a341ef3 /test | |
parent | 488c43771aea482e0212b605bde054bf8cb0533c (diff) | |
download | puppet-cfda651f88d12249f29706d2bedbfddce7a2e6f7.tar.gz puppet-cfda651f88d12249f29706d2bedbfddce7a2e6f7.tar.xz puppet-cfda651f88d12249f29706d2bedbfddce7a2e6f7.zip |
Another round of test-fixes toward eliminating global resource
references. This should have gotten rid of all of them,
and now it's just a question of fixing a few hopefully unrelated
failing tests.
Diffstat (limited to 'test')
-rwxr-xr-x | test/language/lexer.rb | 1 | ||||
-rwxr-xr-x | test/language/parser.rb | 11 | ||||
-rwxr-xr-x | test/network/client/resource.rb | 5 | ||||
-rwxr-xr-x | test/network/handler/resource.rb | 13 | ||||
-rwxr-xr-x | test/network/server/webrick.rb | 3 | ||||
-rwxr-xr-x | test/other/relationships.rb | 2 | ||||
-rwxr-xr-x | test/ral/providers/group.rb | 1 | ||||
-rwxr-xr-x | test/ral/types/cron.rb | 7 | ||||
-rwxr-xr-x | test/ral/types/exec.rb | 9 | ||||
-rwxr-xr-x | test/ral/types/file.rb | 11 | ||||
-rwxr-xr-x | test/ral/types/fileignoresource.rb | 11 | ||||
-rwxr-xr-x | test/ral/types/filesources.rb | 2 | ||||
-rwxr-xr-x | test/ral/types/group.rb | 1 | ||||
-rwxr-xr-x | test/ral/types/host.rb | 13 | ||||
-rwxr-xr-x | test/ral/types/tidy.rb | 2 | ||||
-rwxr-xr-x | test/util/posixtest.rb | 10 | ||||
-rwxr-xr-x | test/util/utiltest.rb | 19 |
17 files changed, 5 insertions, 116 deletions
diff --git a/test/language/lexer.rb b/test/language/lexer.rb index e09828d51..5ac028052 100755 --- a/test/language/lexer.rb +++ b/test/language/lexer.rb @@ -92,7 +92,6 @@ class TestLexer < Test::Unit::TestCase assert_nothing_raised("Failed to lex %s" % file) { lexer.fullscan() } - Puppet::Type.allclear } end diff --git a/test/language/parser.rb b/test/language/parser.rb index 9a2aed711..6ff83054a 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -26,15 +26,6 @@ class TestParser < Test::Unit::TestCase parser.file = file parser.parse } - - Puppet::Type.eachtype { |type| - type.each { |obj| - assert(obj.file, "File is not set on %s" % obj.ref) - assert(obj.name, "Name is not set on %s" % obj.ref) - assert(obj.line, "Line is not set on %s" % obj.ref) - } - } - Puppet::Type.allclear } end @@ -49,7 +40,6 @@ class TestParser < Test::Unit::TestCase config.compile #ast.classes[""].evaluate :scope => config.topscope } - Puppet::Type.allclear } end @@ -680,7 +670,6 @@ file { "/tmp/yayness": manifest = File.join(modpath, "manifest.pp") manifest_texts.each do |txt| - Puppet::Type.allclear File.open(manifest, "w") { |f| f.puts txt } assert_nothing_raised { diff --git a/test/network/client/resource.rb b/test/network/client/resource.rb index eb8e829eb..f3c564d9d 100755 --- a/test/network/client/resource.rb +++ b/test/network/client/resource.rb @@ -38,7 +38,6 @@ class TestResourceClient < Test::Unit::TestCase assert_instance_of(Puppet::TransObject, tobj) - Puppet::Type.allclear obj = nil assert_nothing_raised { obj = tobj.to_type @@ -49,7 +48,6 @@ class TestResourceClient < Test::Unit::TestCase File.unlink(file) # Now test applying - Puppet::Type.allclear result = nil assert_nothing_raised { result = client.apply(tobj) @@ -57,7 +55,6 @@ class TestResourceClient < Test::Unit::TestCase assert(FileTest.exists?(file), "File was not created on apply") # Lastly, test "list" - Puppet::Type.allclear list = nil assert_nothing_raised { list = client.list("user") @@ -70,14 +67,12 @@ class TestResourceClient < Test::Unit::TestCase break if count > 3 assert_instance_of(Puppet::TransObject, tobj) - Puppet::Type.allclear tobj2 = nil assert_nothing_raised { tobj2 = client.describe(tobj.type, tobj.name) } obj = nil - Puppet::Type.allclear assert_nothing_raised { obj = tobj2.to_type } diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb index 00a88b57f..5102291e1 100755 --- a/test/network/handler/resource.rb +++ b/test/network/handler/resource.rb @@ -13,7 +13,6 @@ class TestResourceServer < Test::Unit::TestCase def verify_described(type, described) described.each do |name, trans| - type.clear obj = nil assert_nothing_raised do obj = trans.to_type @@ -28,7 +27,6 @@ class TestResourceServer < Test::Unit::TestCase assert_equal(Puppet::Type.type(:package).defaultprovider.name, obj[:provider]) end end - type.clear end def test_describe_file @@ -64,9 +62,6 @@ class TestResourceServer < Test::Unit::TestCase assert_instance_of(Puppet::TransObject, result) - # Now we have to clear, so that the server's object gets removed - Puppet::Type.type(:file).clear - # And remove the file, so we can verify it gets recreated if i == 0 File.unlink(file) @@ -140,9 +135,6 @@ class TestResourceServer < Test::Unit::TestCase assert_instance_of(Puppet::TransObject, result) - # Now we have to clear, so that the server's object gets removed - Puppet::Type.type(:file).clear - # And remove the file, so we can verify it gets recreated Dir.rmdir(file) @@ -198,8 +190,6 @@ class TestResourceServer < Test::Unit::TestCase bucket = server.list(type.name) } - #type.clear - count = 0 described = {} bucket.each do |obj| @@ -251,8 +241,6 @@ class TestResourceServer < Test::Unit::TestCase filetrans = server.describe("file", file) } - Puppet::Type.type(:file).clear - bucket = Puppet::TransBucket.new bucket.type = "file" bucket.name = "test" @@ -273,7 +261,6 @@ class TestResourceServer < Test::Unit::TestCase yaml = Base64.encode64(YAML::dump(bucket)) } - Puppet::Type.type(:file).clear File.unlink(file) if Base64.decode64(yaml) =~ /(.{20}Loglevel.{20})/ diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb index d3408c166..e44d84dda 100755 --- a/test/network/server/webrick.rb +++ b/test/network/server/webrick.rb @@ -101,9 +101,6 @@ class TestWebrickServer < Test::Unit::TestCase def mk_status_client client = nil - # Otherwise, the client initalization will trip over itself - # since elements created in the last run are still around - Puppet::Type::allclear assert_nothing_raised() { client = Puppet::Network::Client.status.new( diff --git a/test/other/relationships.rb b/test/other/relationships.rb index 88d35ce1f..4e666450e 100755 --- a/test/other/relationships.rb +++ b/test/other/relationships.rb @@ -109,8 +109,6 @@ class TestRelationships < Test::Unit::TestCase execs[0][param], "Incorrect source list") end check_relationship(sources, targets, out[param], refreshers.include?(param)) - - Puppet::Type.allclear end end diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb index 18b0866b9..f912ec51a 100755 --- a/test/ral/providers/group.rb +++ b/test/ral/providers/group.rb @@ -21,7 +21,6 @@ class TestGroupProvider < Test::Unit::TestCase def teardown super - Puppet.type(:group).clear @@tmpgroups.each { |group| unless missing?(group) remove(group) diff --git a/test/ral/types/cron.rb b/test/ral/types/cron.rb index 644494bcc..8e3d25350 100755 --- a/test/ral/types/cron.rb +++ b/test/ral/types/cron.rb @@ -25,7 +25,6 @@ class TestCron < Test::Unit::TestCase def teardown super @crontype.defaultprovider = nil - Puppet::Util::FileType.filetype(:ram).clear end def eachprovider @@ -145,8 +144,6 @@ class TestCron < Test::Unit::TestCase next unless prop.name.to_s == "command" assert(prop.insync?(value), "Property %s is not considered in sync with value %s" % [prop.name, value.inspect]) end - - @crontype.clear end end @@ -247,7 +244,6 @@ class TestCron < Test::Unit::TestCase next unless prop.name.to_s == "minute" assert(prop.insync?(value), "Property %s is not considered in sync with value %s" % [prop.name, value.inspect]) end - @crontype.clear end end @@ -294,8 +290,6 @@ class TestCron < Test::Unit::TestCase # Write it to our file assert_apply(cron) - @crontype.clear - crons = [] assert_nothing_raised { @crontype.instances.each do |cron| @@ -484,7 +478,6 @@ class TestCron < Test::Unit::TestCase cron = @crontype.create(:name => "space testing", :command => string) assert_apply(cron) - cron.class.clear cron = @crontype.create(:name => "space testing", :command => string) # Now make sure that it's correctly in sync diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb index 396d27839..976e3f3ab 100755 --- a/test/ral/types/exec.rb +++ b/test/ral/types/exec.rb @@ -22,8 +22,6 @@ class TestExec < Test::Unit::TestCase def test_numvsstring [0, "0"].each { |val| - Puppet.type(:exec).clear - Puppet.type(:component).clear command = nil output = nil assert_nothing_raised { @@ -50,13 +48,11 @@ class TestExec < Test::Unit::TestCase :path => "/usr/bin:/bin:/usr/sbin:/sbin" ) } - Puppet.type(:exec).clear assert_nothing_raised { command = Puppet.type(:exec).create( :command => "/bin/echo" ) } - Puppet.type(:exec).clear assert_nothing_raised { command = Puppet.type(:exec).create( :command => "/bin/echo", @@ -204,6 +200,7 @@ class TestExec < Test::Unit::TestCase comp = mk_catalog("Testing", file, exec) + Facter.stubs(:to_hash).returns({}) assert_events([:file_created, :executed_command], comp) end @@ -353,10 +350,6 @@ class TestExec < Test::Unit::TestCase if user assert_equal(user.uid, File.stat(file).uid, "File UIDs do not match") end - - # We can't actually test group ownership, unfortunately, because - # behaviour changes wildlly based on platform. - Puppet::Type.allclear end def test_userngroup diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb index 1d523aa40..aaf007e24 100755 --- a/test/ral/types/file.rb +++ b/test/ral/types/file.rb @@ -34,10 +34,10 @@ class TestFile < Test::Unit::TestCase @file = Puppet::Type.type(:file) $method = @method_name Puppet[:filetimeout] = -1 + Facter.stubs(:to_hash).returns({}) end def teardown - Puppet::Util::Storage.clear system("rm -rf %s" % Puppet[:statefile]) super end @@ -420,7 +420,6 @@ class TestFile < Test::Unit::TestCase of.puts "some more text, yo" } } - Puppet.type(:file).clear # now recreate the file assert_nothing_raised() { @@ -456,11 +455,6 @@ class TestFile < Test::Unit::TestCase } assert_events([:file_changed], file) - # verify that we're actually getting notified when a file changes - assert_nothing_raised() { - Puppet.type(:file).clear - } - if path =~ /nonexists/ File.unlink(path) end @@ -711,7 +705,6 @@ class TestFile < Test::Unit::TestCase "Incorrect generated children when recurse == %s" % value.inspect) File.unlink(tmpfile) - Puppet.type(:file).clear end end @@ -1330,7 +1323,6 @@ class TestFile < Test::Unit::TestCase end assert_equal("/my/file/for/testing", file.title) - Puppet::Type.type(:file).clear end end @@ -1646,7 +1638,6 @@ class TestFile < Test::Unit::TestCase assert_nothing_raised("%s conflicted with ensure" % [param]) do Puppet::Type.newfile(:path => file, param => first, :ensure => :file) end - Puppet::Type.type(:file).clear params.each do |other| next if other == param assert_raise(Puppet::Error, "%s and %s did not conflict" % [param, other]) do diff --git a/test/ral/types/fileignoresource.rb b/test/ral/types/fileignoresource.rb index ff867c879..996bca424 100755 --- a/test/ral/types/fileignoresource.rb +++ b/test/ral/types/fileignoresource.rb @@ -18,6 +18,8 @@ class TestFileIgnoreSources < Test::Unit::TestCase rescue system("rm -rf %s" % Puppet[:statefile]) end + + Facter.stubs(:to_hash).returns({}) end #This is not needed unless using md5 (correct me if I'm wrong) @@ -86,8 +88,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase #This file should not assert(!(FileTest.exists?(File.join(topath,sourcefile2)))) - - Puppet::Type.allclear end def test_ignore_with_wildcard @@ -155,8 +155,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase assert(!(FileTest.exists?(File.join(topath,sourcefile2)))) assert(!(FileTest.exists?(File.join(topath,subdir2)))) assert(!(FileTest.exists?(File.join(File.join(topath,subdir),sourcefile2)))) - Puppet::Type.allclear - end def test_ignore_array @@ -236,10 +234,5 @@ class TestFileIgnoreSources < Test::Unit::TestCase assert(!(FileTest.exists?(File.join(topath,subdir2))), "subdir2 in dest") assert(!(FileTest.exists?(File.join(topath,subdir3))), "anotherdir in dest") assert(!(FileTest.exists?(File.join(File.join(topath,subdir),sourcefile2))), "file2 in dest/sub") - - - Puppet::Type.allclear - end - end diff --git a/test/ral/types/filesources.rb b/test/ral/types/filesources.rb index 511065c45..f21fc9b20 100755 --- a/test/ral/types/filesources.rb +++ b/test/ral/types/filesources.rb @@ -21,6 +21,7 @@ class TestFileSources < Test::Unit::TestCase @file = Puppet::Type.type(:file) Puppet[:filetimeout] = -1 Puppet::Util::SUIDManager.stubs(:asuser).yields + Facter.stubs(:to_hash).returns({}) end def teardown @@ -364,7 +365,6 @@ class TestFileSources < Test::Unit::TestCase end def recursive_source_test(fromdir, todir) - Puppet::Type.allclear initstorage tofile = nil trans = nil diff --git a/test/ral/types/group.rb b/test/ral/types/group.rb index d28c8eea5..3c29fe505 100755 --- a/test/ral/types/group.rb +++ b/test/ral/types/group.rb @@ -39,7 +39,6 @@ class TestGroup < Test::Unit::TestCase end def teardown - Puppet.type(:group).clear Puppet::Type.type(:group).defaultprovider = nil super end diff --git a/test/ral/types/host.rb b/test/ral/types/host.rb index 19bc6b4bd..d44fe888c 100755 --- a/test/ral/types/host.rb +++ b/test/ral/types/host.rb @@ -54,19 +54,6 @@ class TestHost < Test::Unit::TestCase return host end - def test_list - assert_nothing_raised do - @hosttype.defaultprovider.prefetch - end - - count = 0 - @hosttype.each do |h| - count += 1 - end - - assert_equal(0, count, "Found hosts in empty file somehow") - end - # Darwin will actually write to netinfo here. if Facter.value(:operatingsystem) != "Darwin" or Process.uid == 0 def test_simplehost diff --git a/test/ral/types/tidy.rb b/test/ral/types/tidy.rb index 60fad6516..4e3bb53b7 100755 --- a/test/ral/types/tidy.rb +++ b/test/ral/types/tidy.rb @@ -207,8 +207,6 @@ class TestTidy < Test::Unit::TestCase assert_apply(tidy) assert(! FileTest.exists?(path), "file did not get tidied") - tidy.class.clear - # Now try one with just an age attribute. time = Time.now - 10 stat = stub 'stat', :mtime => time, :atime => time, :ftype => "file" diff --git a/test/util/posixtest.rb b/test/util/posixtest.rb index 34d68e3a2..8fd11b086 100755 --- a/test/util/posixtest.rb +++ b/test/util/posixtest.rb @@ -35,16 +35,6 @@ class TestPosixUtil < Test::Unit::TestCase end end - def test_get_provider_value - user = nonrootuser - obj = mk_posix_resource(:user, user) - - assert_nothing_raised do - assert_equal(user.uid, get_provider_value(:user, :uid, user.uid)) - assert_equal(user.name, get_provider_value(:user, :name, user.name)) - end - end - def test_gid_and_uid {:user => nonrootuser, :group => nonrootgroup}.each do |type, obj| method = idfield(type) diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb index 35e1446a1..a8dfca9c2 100755 --- a/test/util/utiltest.rb +++ b/test/util/utiltest.rb @@ -264,24 +264,5 @@ class TestPuppetUtil < Test::Unit::TestCase # Puppet::Util.execute(cmd, 0, 0) #} end - - # This is mostly to test #380. - def test_get_provider_value - group = Puppet::Type.type(:group).create :name => "yayness", :ensure => :present - - root = Puppet::Type.type(:user).create :name => "root", :ensure => :present - - val = nil - assert_nothing_raised do - val = Puppet::Util.get_provider_value(:group, :gid, "yayness") - end - assert_nil(val, "returned a value on a missing group") - - # Now make sure we get a value for one we know exists - assert_nothing_raised do - val = Puppet::Util.get_provider_value(:user, :uid, "root") - end - assert_equal(0, val, "got invalid uid for root") - end end |