diff options
author | Luke Kanies <luke@madstop.com> | 2008-04-01 00:45:45 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-04-01 00:45:45 -0500 |
commit | b49fb68f768e8b98c555ef0ae08a7bd22f5d36bd (patch) | |
tree | a3d7964621a58b241d417f1f399629e23c8f9f10 /test | |
parent | 5e78151d1736e2c4cb741c2cbb7c6b5a59ed3e13 (diff) | |
download | puppet-b49fb68f768e8b98c555ef0ae08a7bd22f5d36bd.tar.gz puppet-b49fb68f768e8b98c555ef0ae08a7bd22f5d36bd.tar.xz puppet-b49fb68f768e8b98c555ef0ae08a7bd22f5d36bd.zip |
Fixing the tests in test/ that were broken as
a result of the move to no global resources.
Diffstat (limited to 'test')
-rwxr-xr-x | test/network/handler/resource.rb | 85 | ||||
-rwxr-xr-x | test/ral/type/basic.rb | 85 | ||||
-rwxr-xr-x | test/ral/type/exec.rb | 2 | ||||
-rwxr-xr-x | test/ral/type/filesources.rb | 39 | ||||
-rwxr-xr-x | test/ral/type/host.rb | 10 | ||||
-rwxr-xr-x | test/ral/type/yumrepo.rb | 17 |
6 files changed, 47 insertions, 191 deletions
diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb index 5102291e1..269c9571c 100755 --- a/test/network/handler/resource.rb +++ b/test/network/handler/resource.rb @@ -40,68 +40,38 @@ class TestResourceServer < Test::Unit::TestCase server = Puppet::Network::Handler.resource.new() end - # The first run we create the file on the copy, the second run - # the file is already there so the object should be in sync - 2.times do |i| - [ [nil], - [[:content, :mode], []], - [[], [:content]], - [[:content], [:mode]] - ].each do |ary| - retrieve = ary[0] || [] - ignore = ary[1] || [] - - File.open(file, "w") { |f| f.print str } - - result = nil - assert_nothing_raised do - result = server.describe("file", file, *ary) - end - - assert(result, "Could not retrieve file information") - - assert_instance_of(Puppet::TransObject, result) + [ [nil], + [[:content, :mode], []], + [[], [:content]], + [[:content], [:mode]] + ].each do |ary| + retrieve = ary[0] || [] + ignore = ary[1] || [] - # And remove the file, so we can verify it gets recreated - if i == 0 - File.unlink(file) - end + File.open(file, "w") { |f| f.print str } - object = nil - assert_nothing_raised do - object = result.to_type - end + result = nil + assert_nothing_raised do + result = server.describe("file", file, *ary) + end - assert(object, "Could not create type") + assert(result, "Could not retrieve file information") - retrieve.each do |property| - assert(object.should(property), "Did not retrieve %s" % property) - end + assert_instance_of(Puppet::TransObject, result) - ignore.each do |property| - assert(! object.should(property), "Incorrectly retrieved %s" % property) - end + object = nil + assert_nothing_raised do + object = result.to_type + end - if i == 0 - assert_events([:file_created], object) - else - assert_nothing_raised { - assert(object.insync?(object.retrieve), "Object was not in sync") - } - end + assert(object, "Could not create type") - assert(FileTest.exists?(file), "File did not get recreated") + retrieve.each do |property| + assert(object.should(property), "Did not retrieve %s" % property) + end - if i == 0 - if object.should(:content) - assert_equal(str, File.read(file), "File contents are not the same") - else - assert_equal("", File.read(file), "File content was incorrectly made") - end - end - if FileTest.exists? file - File.unlink(file) - end + ignore.each do |property| + assert(! object.should(property), "Incorrectly retrieved %s" % property) end end end @@ -143,6 +113,8 @@ class TestResourceServer < Test::Unit::TestCase object = result.to_type end + catalog = mk_catalog(object) + assert(object, "Could not create type") retrieve.each do |property| @@ -152,11 +124,6 @@ class TestResourceServer < Test::Unit::TestCase ignore.each do |property| assert(! object.should(property), "Incorrectly retrieved %s" % property) end - - #assert_apply(object) - assert_events([:directory_created], object) - assert(FileTest.directory?(file), "Directory did not get recreated") - Dir.rmdir(file) end end diff --git a/test/ral/type/basic.rb b/test/ral/type/basic.rb deleted file mode 100755 index 3c5faeee0..000000000 --- a/test/ral/type/basic.rb +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../lib/puppettest' - -require 'puppettest' - -class TestBasic < Test::Unit::TestCase - include PuppetTest - - def setup - super - @component = nil - @configfile = nil - @command = nil - - assert_nothing_raised() { - @component = Puppet.type(:component).create( - :name => "yaytest", - :type => "testing" - ) - } - - assert_nothing_raised() { - @filepath = tempfile() - @configfile = Puppet.type(:file).create( - :path => @filepath, - :ensure => "file", - :checksum => "md5" - ) - } - assert_nothing_raised() { - @command = Puppet.type(:exec).create( - :title => "echo", - :command => "echo yay", - :path => ENV["PATH"] - ) - } - @config = mk_catalog(@component, @configfile, @command) - @config.add_edge @component, @configfile - @config.add_edge @component, @command - end - - def teardown - super - stopservices - end - - def test_values - [:ensure, :checksum].each do |param| - prop = @configfile.property(param) - assert(prop, "got no property for %s" % param) - assert(prop.value, "got no value for %s" % param) - end - end - - def test_name_calls - [@command, @configfile].each { |obj| - Puppet.debug "obj is %s" % obj - assert_nothing_raised(){ - obj.name - } - } - end - - def test_name_equality - assert_equal(@filepath, @configfile.title) - - assert_equal("echo", @command.title) - end - - def test_object_retrieval - [@command, @configfile].each { |obj| - assert_equal(obj.class[obj.name].object_id, obj.object_id, - "%s did not match class version" % obj.ref) - } - end - - def test_paths - [@configfile, @command, @component].each { |obj| - assert_nothing_raised { - assert_instance_of(String, obj.path) - } - } - end -end diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb index 3444b1312..8c7c3f69b 100755 --- a/test/ral/type/exec.rb +++ b/test/ral/type/exec.rb @@ -238,6 +238,8 @@ class TestExec < Test::Unit::TestCase :command => "cat %s %s" % [exe, oexe], :path => ENV["PATH"] ) + + catalog = mk_catalog(file, baseobj, ofile, exec, cat) rels = nil assert_nothing_raised do diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb index f21fc9b20..19b3001d6 100755 --- a/test/ral/type/filesources.rb +++ b/test/ral/type/filesources.rb @@ -125,16 +125,6 @@ class TestFileSources < Test::Unit::TestCase File.open(target, "w") { |f| f.puts "yay" } File.symlink(target, source) - file[:links] = :ignore - assert_nil(property.describe(source), - "Links were not ignored") - - file[:links] = :manage - # We can't manage links at this point - assert_raise(Puppet::Network::Handler::FileServerError) do - property.describe(source) - end - # And then make sure links get followed, otherwise file[:links] = :follow assert_equal("file", property.describe(source)[:type]) @@ -744,33 +734,18 @@ class TestFileSources < Test::Unit::TestCase File.open(source, "w") { |f| f.puts "yay" } File.symlink(source, link) - file = nil - assert_nothing_raised { - file = Puppet.type(:file).create( - :name => dest, - :source => link - ) - } + file = Puppet.type(:file).create(:name => dest, :source => link) - # Default to skipping links - assert_events([], file) - assert(! FileTest.exists?(dest), "Created link") + catalog = mk_catalog(file) + + # Default to managing links + catalog.apply + assert(FileTest.symlink?(dest), "Did not create link") # Now follow the links file[:links] = :follow - assert_events([:file_created], file) + catalog.apply assert(FileTest.file?(dest), "Destination is not a file") - - # Now copy the links - #assert_raise(Puppet::Network::Handler::FileServerError) { - trans = nil - assert_nothing_raised { - file[:links] = :manage - comp = mk_catalog(file) - trans = comp.apply - } - - assert(trans.failed?(file), "Object did not fail to copy links") end def test_changes diff --git a/test/ral/type/host.rb b/test/ral/type/host.rb index 124563cbc..df7cc508f 100755 --- a/test/ral/type/host.rb +++ b/test/ral/type/host.rb @@ -55,16 +55,12 @@ class TestHost < Test::Unit::TestCase end def test_list + list = nil assert_nothing_raised do - @hosttype.defaultprovider.prefetch + list = @hosttype.defaultprovider.instances end - count = 0 - @hosttype.each do |h| - count += 1 - end - - assert_equal(0, count, "Found hosts in empty file somehow") + assert_equal(0, list.length, "Found hosts in empty file somehow") end # Darwin will actually write to netinfo here. diff --git a/test/ral/type/yumrepo.rb b/test/ral/type/yumrepo.rb index 899a02135..273179bc4 100755 --- a/test/ral/type/yumrepo.rb +++ b/test/ral/type/yumrepo.rb @@ -17,6 +17,9 @@ class TestYumRepo < Test::Unit::TestCase f.print "[main]\nreposdir=#{@yumdir} /no/such/dir\n" end Puppet.type(:yumrepo).yumconf = @yumconf + + # It needs to be reset each time, otherwise the cache is used. + Puppet.type(:yumrepo).inifile = nil end # Modify one existing section @@ -24,19 +27,17 @@ class TestYumRepo < Test::Unit::TestCase copy_datafiles devel = make_repo("development", { :descr => "New description" }) current_values = devel.retrieve + assert_equal("development", devel[:name]) - assert_equal('Fedora Core $releasever - Development Tree', - current_values[devel.property(:descr)]) - assert_equal('New description', - devel.property(:descr).should) + assert_equal('Fedora Core $releasever - Development Tree', current_values[devel.property(:descr)]) + assert_equal('New description', devel.property(:descr).should) assert_apply(devel) + inifile = Puppet.type(:yumrepo).read() assert_equal('New description', inifile['development']['name']) - assert_equal('Fedora Core $releasever - $basearch - Base', - inifile['base']['name']) + assert_equal('Fedora Core $releasever - $basearch - Base', inifile['base']['name']) assert_equal("foo\n bar\n baz", inifile['base']['exclude']) - assert_equal(['base', 'development', 'main'], - all_sections(inifile)) + assert_equal(['base', 'development', 'main'], all_sections(inifile)) end # Create a new section |