diff options
| author | Luke Kanies <luke@madstop.com> | 2007-11-19 01:36:48 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-11-19 01:36:48 -0600 |
| commit | 2b14f627aca1d5be69cf6606044df4d6e67f6eba (patch) | |
| tree | a20db3a608af483f598f482e743868413da8fd8f /test/ral | |
| parent | 9cf477b6cc771eab7bd29d18c49128571e877987 (diff) | |
Reverting the changes I'd made toward removing the global
resources. These are commits:
c19835ce9f8a5138b30a1a32ca741c996b0916d2
9290cc89a2206fb5204578f8e91208857a48b147
ffb4c2dbc7314b364d25e4f7be599ef05b767b44
Diffstat (limited to 'test/ral')
| -rwxr-xr-x | test/ral/types/basic.rb | 7 | ||||
| -rwxr-xr-x | test/ral/types/cron.rb | 14 | ||||
| -rwxr-xr-x | test/ral/types/exec.rb | 13 | ||||
| -rwxr-xr-x | test/ral/types/file.rb | 130 | ||||
| -rwxr-xr-x | test/ral/types/file/target.rb | 26 | ||||
| -rwxr-xr-x | test/ral/types/filebucket.rb | 24 | ||||
| -rwxr-xr-x | test/ral/types/fileignoresource.rb | 7 | ||||
| -rwxr-xr-x | test/ral/types/filesources.rb | 10 | ||||
| -rwxr-xr-x | test/ral/types/host.rb | 4 | ||||
| -rwxr-xr-x | test/ral/types/package.rb | 1 | ||||
| -rwxr-xr-x | test/ral/types/parameter.rb | 5 | ||||
| -rwxr-xr-x | test/ral/types/schedule.rb | 39 | ||||
| -rwxr-xr-x | test/ral/types/sshkey.rb | 18 | ||||
| -rwxr-xr-x | test/ral/types/tidy.rb | 14 |
14 files changed, 178 insertions, 134 deletions
diff --git a/test/ral/types/basic.rb b/test/ral/types/basic.rb index 862beeadc..4427238bf 100755 --- a/test/ral/types/basic.rb +++ b/test/ral/types/basic.rb @@ -68,6 +68,13 @@ class TestBasic < Test::Unit::TestCase 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 { diff --git a/test/ral/types/cron.rb b/test/ral/types/cron.rb index d6f29efe4..a9a00240c 100755 --- a/test/ral/types/cron.rb +++ b/test/ral/types/cron.rb @@ -150,6 +150,20 @@ class TestCron < Test::Unit::TestCase end end + def test_makeandretrievecron + %w{storeandretrieve a-name another-name more_naming SomeName}.each do |name| + cron = mkcron(name) + comp = mk_configuration(name, cron) + trans = assert_events([:cron_created], comp, name) + + cron.provider.class.prefetch + cron = nil + + assert(cron = Puppet.type(:cron)[name], "Could not retrieve named cron") + assert_instance_of(Puppet.type(:cron), cron) + end + end + # Do input validation testing on all of the parameters. def test_arguments values = { diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb index ed0ea9980..11a6d4055 100755 --- a/test/ral/types/exec.rb +++ b/test/ral/types/exec.rb @@ -203,45 +203,42 @@ class TestExec < Test::Unit::TestCase ) comp = mk_configuration("Testing", file, exec) - Puppet::Node::Facts.indirection.stubs(:terminus_class).returns(:memory) assert_events([:file_created, :executed_command], comp) end # Verify that we auto-require any managed scripts. def test_autorequire_files - config = mk_configuration - exe = tempfile() oexe = tempfile() sh = %x{which sh} File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" } - file = config.create_resource(:file, + file = Puppet.type(:file).create( :path => oexe, :source => exe, :mode => 755 ) basedir = File.dirname(oexe) - baseobj = config.create_resource(:file, + baseobj = Puppet.type(:file).create( :path => basedir, :source => exe, :mode => 755 ) - ofile = config.create_resource(:file, + ofile = Puppet.type(:file).create( :path => exe, :mode => 755 ) - exec = config.create_resource(:exec, + exec = Puppet.type(:exec).create( :command => oexe, :path => ENV["PATH"], :cwd => basedir ) - cat = config.create_resource(:exec, + cat = Puppet.type(:exec).create( :command => "cat %s %s" % [exe, oexe], :path => ENV["PATH"] ) diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb index 8435855e6..73095a783 100755 --- a/test/ral/types/file.rb +++ b/test/ral/types/file.rb @@ -3,12 +3,10 @@ require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' -require 'puppettest/support/utils' require 'fileutils' class TestFile < Test::Unit::TestCase include PuppetTest::FileTesting - include PuppetTest::Support::Utils # hmmm # this is complicated, because we store references to the created # objects in a central store @@ -34,8 +32,6 @@ class TestFile < Test::Unit::TestCase @file = Puppet::Type.type(:file) $method = @method_name Puppet[:filetimeout] = -1 - Facter.stubs(:each) - Facter.stubs(:to_hash).returns({}) end def teardown @@ -518,7 +514,7 @@ class TestFile < Test::Unit::TestCase test = File.join(path, "file") File.open(test, "w") { |f| f.puts "yay" } assert_nothing_raised() { ret = dir.localrecurse(true) } - fileobj = config.resource(:file, test) + fileobj = @file[test] assert(fileobj, "child object was not created") assert_equal([fileobj], ret, "child object was not returned") @@ -562,7 +558,7 @@ class TestFile < Test::Unit::TestCase assert_nothing_raised() { ret = dir.localrecurse(true) } assert_equal([bad], ret.collect { |f| f.title }, "purge failed") - badobj = config.resource(:file, bad) + badobj = @file[bad] assert(badobj, "did not create bad object") end @@ -758,6 +754,43 @@ class TestFile < Test::Unit::TestCase assert(file.insync?(currentvalues)) end + def test_remove + basedir = tempfile() + subdir = File.join(basedir, "this") + FileUtils.mkdir_p(subdir) + + dir = nil + assert_nothing_raised { + dir = Puppet.type(:file).create( + :path => basedir, + :recurse => true, + :check => %w{owner mode group} + ) + } + mk_configuration dir + + assert_nothing_raised { + dir.eval_generate + } + + obj = nil + assert_nothing_raised { + obj = Puppet.type(:file)[subdir] + } + + assert(obj, "Could not retrieve subdir object") + + assert_nothing_raised { + obj.remove(true) + } + + assert_nothing_raised { + obj = Puppet.type(:file)[subdir] + } + + assert_nil(obj, "Retrieved removed object") + end + def test_path dir = tempfile() @@ -777,14 +810,14 @@ class TestFile < Test::Unit::TestCase :check => %w{mode owner group} ) } - config = mk_configuration dirobj + mk_configuration dirobj assert_nothing_raised { dirobj.eval_generate } assert_nothing_raised { - file = config.resource(:file, path) + file = dirobj.class[path] } assert(file, "Could not retrieve file object") @@ -796,14 +829,12 @@ class TestFile < Test::Unit::TestCase basedir = tempfile() subfile = File.join(basedir, "subfile") - config = Puppet::Node::Configuration.new - - baseobj = config.create_resource(:file, + baseobj = Puppet.type(:file).create( :name => basedir, :ensure => "directory" ) - subobj = config.create_resource(:file, + subobj = Puppet.type(:file).create( :name => subfile, :ensure => "file" ) @@ -1098,17 +1129,18 @@ class TestFile < Test::Unit::TestCase file = tempfile() newfile = tempfile() - config = mk_configuration - File.open(file, "w", 0411) { |f| f.puts "yayness" } - resource = config.create_resource(:file, - :path => file, :content => "rahness\n", :backup => ".puppet-bak" - ) + obj = nil + assert_nothing_raised { + obj = Puppet::Type.type(:file).create( + :path => file, :content => "rahness\n", :backup => ".puppet-bak" + ) + } - assert_apply(config) + assert_apply(obj) - backupfile = file + resource[:backup] + backupfile = file + obj[:backup] @@tmpfiles << backupfile assert(FileTest.exists?(backupfile), "Backup file %s does not exist" % backupfile) @@ -1119,15 +1151,13 @@ class TestFile < Test::Unit::TestCase bucket = "bucket" bpath = tempfile() Dir.mkdir(bpath) - config.create_resource(:filebucket, + Puppet::Type.type(:filebucket).create( :title => bucket, :path => bpath ) - resource[:backup] = bucket - resource[:content] = "New content" - - resource.finish - assert_apply(config) + obj[:backup] = bucket + obj[:content] = "New content" + assert_apply(obj) md5 = "18cc17fa3047fcc691fdf49c0a7f539a" dir, file, pathfile = Puppet::Network::Handler.filebucket.paths(bpath, md5) @@ -1256,20 +1286,19 @@ class TestFile < Test::Unit::TestCase # this file should get removed File.open(purgee, "w") { |f| f.puts "footest" } - config = mk_configuration - - lfobj = config.create_resource(:file, + lfobj = Puppet::Type.newfile( :title => "localfile", :path => localfile, :content => "rahtest", :backup => false ) - destobj = config.create_resource(:file, :title => "destdir", :path => destdir, + destobj = Puppet::Type.newfile(:title => "destdir", :path => destdir, :source => sourcedir, :backup => false, :recurse => true) + config = mk_configuration(lfobj, destobj) config.apply assert(FileTest.exists?(dsourcefile), "File did not get copied") @@ -1402,11 +1431,10 @@ class TestFile < Test::Unit::TestCase :link => proc { File.symlink(linkdest, path) } } - config = mk_configuration - - bucket = config.create_resource :filebucket, :name => "main", :path => tempfile() + bucket = Puppet::Type.newfilebucket :name => "main", :path => tempfile() - obj = config.create_resource :file, :path => path, :force => true, :links => :manage + obj = Puppet::Type.newfile :path => path, :force => true, + :links => :manage Puppet[:trace] = true ["main", false].each do |backup| @@ -1529,17 +1557,15 @@ class TestFile < Test::Unit::TestCase dfiles = [File.join(dest, "1"), File.join(dest, "dir", "2")] bpath = tempfile - - config = mk_configuration - bucket = config.create_resource :filebucket, :name => "rtest", :path => bpath + bucket = Puppet::Type.type(:filebucket).create :name => "rtest", :path => bpath dipper = bucket.bucket dipper = Puppet::Network::Handler.filebucket.new( :Path => bpath ) assert(dipper, "did not receive bucket client") - file = config.create_resource :file, :path => dest, :source => source, :recurse => true, :backup => "rtest" + file = Puppet::Type.newfile :path => dest, :source => source, :recurse => true, :backup => "rtest" - config.apply + assert_apply(file) dfiles.each do |f| assert(FileTest.exists?(f), "destfile %s was not created" % f) end @@ -1549,7 +1575,7 @@ class TestFile < Test::Unit::TestCase f.puts "boo: %s" % File.basename(sf) } } - config.apply + assert_apply(file) dfiles.each do |f| assert_equal("boo: %s\n" % File.basename(f), File.read(f), "file was not copied correctly") @@ -1574,8 +1600,7 @@ class TestFile < Test::Unit::TestCase def test_backup path = tempfile() - config = Puppet::Node::Configuration.new - file = config.create_resource :file, :path => path, :content => "yay" + file = Puppet::Type.newfile :path => path, :content => "yay" [false, :false, "false"].each do |val| assert_nothing_raised do @@ -1604,7 +1629,7 @@ class TestFile < Test::Unit::TestCase assert_equal("main", file.bucket, "file's bucket was not set") # And then an existing bucket - obj = config.create_resource :filebucket, :name => "testing" + obj = Puppet::Type.type(:filebucket).create :name => "testing" bucket = obj.bucket assert_nothing_raised do @@ -1620,12 +1645,12 @@ class TestFile < Test::Unit::TestCase file = File.join(dir, "file") File.open(file, "w") { |f| f.puts "" } obj = Puppet::Type.newfile :path => dir, :recurse => true, :mode => 0755 - config = mk_configuration obj + mk_configuration obj assert_equal("/%s" % obj.ref, obj.path) list = obj.eval_generate - fileobj = config.resource(:file, file) + fileobj = obj.class[file] assert(fileobj, "did not generate file object") assert_equal("/%s" % fileobj.ref, fileobj.path, "did not generate correct subfile path") end @@ -1642,8 +1667,7 @@ class TestFile < Test::Unit::TestCase # Testing #434 def test_stripping_extra_slashes_during_lookup - config = mk_configuration - file = config.create_resource(:file, :path => "/one/two") + file = Puppet::Type.newfile(:path => "/one/two") %w{/one/two/ /one/two /one//two //one//two//}.each do |path| assert(Puppet::Type.type(:file)[path], "could not look up file via path %s" % path) end @@ -1738,14 +1762,14 @@ class TestFile < Test::Unit::TestCase assert_nothing_raised("Failure when recursing") do children = obj.eval_generate end - assert(config.resource(:file, subdir), "did not create subdir object") + assert(obj.class[subdir], "did not create subdir object") children.each do |c| assert_nothing_raised("Failure when recursing on %s" % c) do c.configuration = config others = c.eval_generate end end - oobj = config.resource(:file, other) + oobj = obj.class[other] assert(oobj, "did not create other object") assert_nothing_raised do @@ -1756,14 +1780,12 @@ class TestFile < Test::Unit::TestCase # Make sure we default to the "puppet" filebucket, rather than a string def test_backup_defaults_to_bucket path = tempfile - config = Puppet::Node::Configuration.new - config.add_resource(Puppet::Type.type(:filebucket).create_default_resources) - file = config.create_resource :file, :path => path, :content => 'some content' + file = Puppet::Type.newfile(:path => path, :content => 'some content') file.finish - assert_instance_of(Puppet::Network::Client.dipper, file.bucket, + assert_instance_of(Puppet::Network::Client::Dipper, file.bucket, "did not default to a filebucket for backups") - assert_equal(config.resource(:filebucket, "puppet").bucket, file.bucket, + assert_equal(Puppet::Type.type(:filebucket)["puppet"].bucket, file.bucket, "did not default to the 'puppet' filebucket") end @@ -1782,7 +1804,7 @@ class TestFile < Test::Unit::TestCase assert_nothing_raised do children = obj.eval_generate end - fobj = config.resource(:file,file) + fobj = obj.class[file] assert(fobj, "did not create file object") assert(fobj.should(:ensure) != :directory, "ensure was passed to child") end diff --git a/test/ral/types/file/target.rb b/test/ral/types/file/target.rb index cc53e2645..f5cbe4a45 100755 --- a/test/ral/types/file/target.rb +++ b/test/ral/types/file/target.rb @@ -3,11 +3,9 @@ require File.dirname(__FILE__) + '/../../../lib/puppettest' require 'puppettest' -require 'puppettest/support/assertions' require 'fileutils' class TestFileTarget < Test::Unit::TestCase - include PuppetTest include PuppetTest::FileTesting def setup @@ -46,7 +44,7 @@ class TestFileTarget < Test::Unit::TestCase def test_linkrecurse dest = tempfile() link = @file.create :path => tempfile(), :recurse => true, :ensure => dest - config = mk_configuration link + mk_configuration link ret = nil @@ -64,8 +62,7 @@ class TestFileTarget < Test::Unit::TestCase assert_equal(:directory, link.should(:ensure), "ensure was not set to directory") assert_equal([File.join(link.title, "one")], ret.collect { |f| f.title }, "Did not get linked file") - oneobj = config.resource(:file, File.join(link.title, "one")) - + oneobj = @file[File.join(link.title, "one")] assert_equal(one, oneobj.should(:target), "target was not set correctly") oneobj.remove @@ -84,7 +81,7 @@ class TestFileTarget < Test::Unit::TestCase "Did not get links back") returns.each do |path| - obj = config.resource(:file, path) + obj = @file[path] assert(path, "did not get obj for %s" % path) sdest = File.join(dest, File.basename(path)) assert_equal(sdest, obj.should(:target), @@ -102,14 +99,15 @@ class TestFileTarget < Test::Unit::TestCase system("touch %s" % file) link = nil - config = mk_configuration - link = config.create_resource(:file, - :ensure => source, - :path => path, - :recurse => true - ) + assert_nothing_raised { + link = Puppet.type(:file).create( + :ensure => source, + :path => path, + :recurse => true + ) + } - config.apply + assert_apply(link) sublink = File.join(path, "subdir") linkpath = File.join(sublink, "file") @@ -118,7 +116,7 @@ class TestFileTarget < Test::Unit::TestCase assert(File.symlink?(linkpath), "path is not a link") assert_equal(file, File.readlink(linkpath)) - assert_nil(config.resource(:file, sublink), "objects were not removed") + assert_nil(@file[sublink], "objects were not removed") assert_equal([], link.evaluate, "Link is not in sync") end diff --git a/test/ral/types/filebucket.rb b/test/ral/types/filebucket.rb index 3681febf4..ecfe0e167 100755 --- a/test/ral/types/filebucket.rb +++ b/test/ral/types/filebucket.rb @@ -3,12 +3,10 @@ require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' -require 'puppettest/support/utils' require 'fileutils' class TestFileBucket < Test::Unit::TestCase include PuppetTest::FileTesting - include PuppetTest::Support::Utils # hmmm # this is complicated, because we store references to the created # objects in a central store @@ -65,9 +63,14 @@ class TestFileBucket < Test::Unit::TestCase def test_simplebucket name = "yayness" bucketpath = tempfile() - bucket_resource = mkbucket(name, bucketpath) + mkbucket(name, bucketpath) - bucket = bucket_resource.bucket + bucket = nil + assert_nothing_raised { + bucket = Puppet.type(:filebucket).bucket(name) + } + + assert_instance_of(Puppet::Network::Client.dipper, bucket) md5 = nil newpath = tempfile() @@ -106,16 +109,15 @@ class TestFileBucket < Test::Unit::TestCase end def test_fileswithbuckets - Facter.stubs(:to_hash).returns({}) name = "yayness" - resource = mkbucket(name, tempfile()) + mkbucket(name, tempfile()) - config = mk_configuration resource - - bucket = resource.bucket + bucket = nil + assert_nothing_raised { + bucket = Puppet.type(:filebucket).bucket(name) + } file = mktestfile() - config.add_resource(file) assert_nothing_raised { file[:backup] = name } @@ -131,7 +133,7 @@ class TestFileBucket < Test::Unit::TestCase # file[:backup] = true #} - config.apply + assert_apply(file) # so, we've now replaced the file with the opath file assert_equal( diff --git a/test/ral/types/fileignoresource.rb b/test/ral/types/fileignoresource.rb index 501672ab7..5c7536453 100755 --- a/test/ral/types/fileignoresource.rb +++ b/test/ral/types/fileignoresource.rb @@ -3,13 +3,11 @@ require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' -require 'puppettest/support/utils' require 'cgi' require 'fileutils' class TestFileIgnoreSources < Test::Unit::TestCase include PuppetTest::FileTesting - include PuppetTest::Support::Utils def setup super @@ -20,7 +18,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase end end - #This is not needed unless using md5 (correct me if I'm wrong) +#This is not needed unless using md5 (correct me if I'm wrong) def initstorage Puppet::Util::Storage.init Puppet::Util::Storage.load @@ -32,7 +30,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase end def test_ignore_simple_source - Facter.stubs(:to_hash).returns({}) #Temp directory to run tests in path = tempfile() @@ -92,7 +89,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase end def test_ignore_with_wildcard - Facter.stubs(:to_hash).returns({}) #Temp directory to run tests in path = tempfile() @@tmpfiles.push path @@ -162,7 +158,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase end def test_ignore_array - Facter.stubs(:to_hash).returns({}) #Temp directory to run tests in path = tempfile() @@tmpfiles.push path diff --git a/test/ral/types/filesources.rb b/test/ral/types/filesources.rb index bfbc185e3..1f22fc9e0 100755 --- a/test/ral/types/filesources.rb +++ b/test/ral/types/filesources.rb @@ -3,13 +3,11 @@ require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' -require 'puppettest/support/assertions' require 'cgi' require 'fileutils' require 'mocha' class TestFileSources < Test::Unit::TestCase - include PuppetTest include PuppetTest::FileTesting def setup super @@ -287,7 +285,7 @@ class TestFileSources < Test::Unit::TestCase end assert_equal([destfile], sourced, "Did not get correct list of sourced objects") - dfileobj = config.resource(:file, destfile) + dfileobj = @file[destfile] assert(dfileobj, "Did not create destfile object") assert_equal([dfileobj], result) @@ -303,7 +301,7 @@ class TestFileSources < Test::Unit::TestCase result, sourced = obj.sourcerecurse(true) end assert_equal([destfile], sourced, "Did not get correct list of sourced objects") - dfileobj = config.resource(:file, destfile) + dfileobj = @file[destfile] assert(dfileobj, "Did not create destfile object with a missing source") assert_equal([dfileobj], result) dfileobj.remove @@ -417,6 +415,9 @@ class TestFileSources < Test::Unit::TestCase def test_sources_with_deleted_destfiles fromdir, todir, one, two = run_complex_sources assert(FileTest.exists?(todir)) + + # We shouldn't have a 'two' file object in memory + assert_nil(@file[two], "object for 'two' is still in memory") # then delete a file File.unlink(two) @@ -938,6 +939,7 @@ class TestFileSources < Test::Unit::TestCase end File.unlink(file1) File.unlink(file3) + Puppet.err :yay assert_apply(obj) assert(FileTest.exists?(file1), "File from source 1 was not copied") diff --git a/test/ral/types/host.rb b/test/ral/types/host.rb index 5e91a8c58..1013651c5 100755 --- a/test/ral/types/host.rb +++ b/test/ral/types/host.rb @@ -154,13 +154,11 @@ class TestHost < Test::Unit::TestCase def test_puppetalias host = mkhost() - config = mk_configuration(host) - assert_nothing_raised { host[:alias] = "testing" } - same = config.resource(:host, "testing") + same = host.class["testing"] assert(same, "Could not retrieve by alias") end end diff --git a/test/ral/types/package.rb b/test/ral/types/package.rb index d09f7d9b7..7d0caa0ba 100755 --- a/test/ral/types/package.rb +++ b/test/ral/types/package.rb @@ -9,7 +9,6 @@ require 'mocha' $platform = Facter["operatingsystem"].value class TestPackages < Test::Unit::TestCase - include PuppetTest include PuppetTest::FileTesting def setup super diff --git a/test/ral/types/parameter.rb b/test/ral/types/parameter.rb index 7eda05bb5..1d402cb85 100755 --- a/test/ral/types/parameter.rb +++ b/test/ral/types/parameter.rb @@ -113,7 +113,8 @@ class TestParameter < Test::Unit::TestCase inst = type.create(:name => "test") - config = mk_configuration(inst) + config = mk_configuration + inst.configuration = config assert_nothing_raised("Could not create shadowed param") { inst[:alias] = "foo" @@ -130,7 +131,7 @@ class TestParameter < Test::Unit::TestCase assert_instance_of(param, obj, "alias is an instance of the wrong class") # Make sure the alias got created - assert(config.resource(inst.class.name, "foo"), "Did not retrieve object by its alias") + assert(type["foo"], "Did not retrieve object by its alias") # Now try it during initialization other = nil diff --git a/test/ral/types/schedule.rb b/test/ral/types/schedule.rb index 06698f288..2870b8db6 100755 --- a/test/ral/types/schedule.rb +++ b/test/ral/types/schedule.rb @@ -242,23 +242,24 @@ class TestSchedule < Test::Unit::TestCase s = mksched s[:period] = :hourly + f = nil path = tempfile() - f = Puppet.type(:file).create( - :name => path, - :schedule => s.name, - :ensure => "file" - ) - - config = mk_configuration(s, f) + assert_nothing_raised { + f = Puppet.type(:file).create( + :name => path, + :schedule => s.name, + :ensure => "file" + ) + } assert(f.scheduled?, "File is not scheduled to run") - config.apply + assert_apply(f) assert(! f.scheduled?, "File is scheduled to run already") File.unlink(path) - config.apply + assert_apply(f) assert(! FileTest.exists?(path), "File was created when not scheduled") end @@ -286,17 +287,25 @@ class TestSchedule < Test::Unit::TestCase # Verify that each of our default schedules exist def test_defaultschedules - defaults = nil - assert_nothing_raised("Could not create default schedules") do - defaults = Puppet.type(:schedule).create_default_resources + assert_nothing_raised do + Puppet.type(:schedule).mkdefaultschedules end s = {} %w{puppet hourly daily weekly monthly}.each { |period| - schedule = defaults.find { |r| r.title == period } - assert(schedule, "Could not find %s schedule" % + obj = Puppet.type(:schedule)[period] + assert(obj, "Could not find %s schedule" % period) - s[period] = schedule + s[period] = obj } + assert_nothing_raised("Could not rerun mkdefaultschedules") do + Puppet.type(:schedule).mkdefaultschedules + end + s.each do |period, obj| + newobj = Puppet.type(:schedule)[period] + assert(newobj, "somehow lost schedule for %s" % period) + assert_equal(obj.object_id, newobj.object_id, + "created a new schedule instead of reusing existing one") + end end def test_period_with_repeat diff --git a/test/ral/types/sshkey.rb b/test/ral/types/sshkey.rb index a2daf6cfb..c99f7562a 100755 --- a/test/ral/types/sshkey.rb +++ b/test/ral/types/sshkey.rb @@ -102,8 +102,6 @@ class TestSSHKey < Test::Unit::TestCase def test_moddingkey key = mkkey() - config = mk_configuration(key) - assert_events([:sshkey_created], key) key.retrieve @@ -115,7 +113,7 @@ class TestSSHKey < Test::Unit::TestCase assert_events([:sshkey_changed], key) aliases.each do |name| - assert_equal(key, config.resource(:sshkey, name), + assert_equal(key, key.class[name], "alias was not set") end end @@ -133,13 +131,12 @@ class TestSSHKey < Test::Unit::TestCase def test_puppetalias key = mkkey() - config = mk_configuration(key) assert_nothing_raised { key[:alias] = "testing" } - same = config.resource(:sshkey, "testing") + same = key.class["testing"] assert(same, "Could not retrieve by alias") end @@ -171,14 +168,13 @@ class TestSSHKey < Test::Unit::TestCase keys << k names << k.name } - config = mk_configuration(*keys) - config.apply - + assert_apply(*keys) + keys.clear + Puppet.type(:sshkey).clear newkey = mkkey() - config = mk_configuration(newkey) + #newkey[:ensure] = :present names << newkey.name - - config.apply + assert_apply(newkey) # Verify we can retrieve that info assert_nothing_raised("Could not retrieve after second write") { diff --git a/test/ral/types/tidy.rb b/test/ral/types/tidy.rb index 6cdf0f050..e95f26b95 100755 --- a/test/ral/types/tidy.rb +++ b/test/ral/types/tidy.rb @@ -3,10 +3,8 @@ require File.dirname(__FILE__) + '/../../lib/puppettest' require 'puppettest' -require 'puppettest/support/utils' class TestTidy < Test::Unit::TestCase - include PuppetTest include PuppetTest::FileTesting def mktmpfile # because luke's home directory is on nfs, it can't be used for testing @@ -203,10 +201,16 @@ class TestTidy < Test::Unit::TestCase path = tempfile() File.open(path, "w") { |f| 10.times { f.puts "yayness " } } tidy = Puppet::Type.type(:tidy).create :path => path, :size => "1b" - config = mk_configuration(tidy) - - config.apply + + assert_apply(tidy) + assert(! FileTest.exists?(path), "file did not get tidied") + + # Now try one with just an age attribute. + File.open(path, "w") { |f| 10.times { f.puts "yayness " } } + tidy = Puppet::Type.type(:tidy).create :path => path, :age => "5s" + + assert_apply(tidy) assert(! FileTest.exists?(path), "file did not get tidied") end |
