diff options
Diffstat (limited to 'test/types')
-rwxr-xr-x | test/types/exec.rb | 2 | ||||
-rwxr-xr-x | test/types/file.rb | 40 | ||||
-rwxr-xr-x | test/types/group.rb | 8 | ||||
-rwxr-xr-x | test/types/package.rb | 2 | ||||
-rwxr-xr-x | test/types/type.rb | 9 |
5 files changed, 31 insertions, 30 deletions
diff --git a/test/types/exec.rb b/test/types/exec.rb index 53d343010..305f27d56 100755 --- a/test/types/exec.rb +++ b/test/types/exec.rb @@ -144,7 +144,7 @@ class TestExec < Test::Unit::TestCase file.retrieve sum = file.state(:checksum) - assert_equal(sum.is, sum.should) + assert(sum.insync?, "checksum is not in sync") events = trans.evaluate.collect { |event| event.event } diff --git a/test/types/file.rb b/test/types/file.rb index 027b52b81..c6cccae81 100755 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -388,29 +388,24 @@ class TestFile < Test::Unit::TestCase :checksum => type ) } - comp = Puppet.type(:component).create( - :name => "checksum %s" % type - ) - comp.push file trans = nil file.retrieve if file.title !~ /nonexists/ sum = file.state(:checksum) - assert_equal(sum.is, sum.should) - assert(sum.insync?) + assert(sum.insync?, "file is not in sync") end - events = assert_apply(comp) + events = assert_apply(file) assert(! events.include?(:file_changed), "File incorrectly changed") - assert_events([], comp) + assert_events([], file) # We have to sleep because the time resolution of the time-based # mechanisms is greater than one second - sleep 1 + sleep 1 if type =~ /time/ assert_nothing_raised() { File.open(path,File::CREAT|File::TRUNC|File::WRONLY) { |of| @@ -418,7 +413,6 @@ class TestFile < Test::Unit::TestCase } } Puppet.type(:file).clear - Puppet.type(:component).clear # now recreate the file assert_nothing_raised() { @@ -427,19 +421,19 @@ class TestFile < Test::Unit::TestCase :checksum => type ) } - comp = Puppet.type(:component).create( - :name => "checksum, take 2, %s" % type - ) - comp.push file trans = nil - # If the file was missing, it should not generate an event - # when it gets created. - #if path =~ /nonexists/ - # assert_events([], comp) - #else - assert_events([:file_changed], comp) - #end + assert_events([:file_changed], file) + + # Run it a few times to make sure we aren't getting + # spurious changes. + assert_nothing_raised do + file.state(:checksum).retrieve + end + assert(file.state(:checksum).insync?, + "checksum is not in sync") + + sleep 1.1 if type =~ /time/ assert_nothing_raised() { File.unlink(path) File.open(path,File::CREAT|File::TRUNC|File::WRONLY) { |of| @@ -451,13 +445,11 @@ class TestFile < Test::Unit::TestCase of.flush } } - #assert_apply(comp) - assert_events([:file_changed], comp) + assert_events([:file_changed], file) # verify that we're actually getting notified when a file changes assert_nothing_raised() { Puppet.type(:file).clear - Puppet.type(:component).clear } if path =~ /nonexists/ diff --git a/test/types/group.rb b/test/types/group.rb index c681b5bd0..e12089256 100755 --- a/test/types/group.rb +++ b/test/types/group.rb @@ -136,19 +136,17 @@ class TestGroup < Test::Unit::TestCase def test_mkgroup gobj = nil - comp = nil name = "pptestgr" assert_nothing_raised { gobj = Puppet.type(:group).create( :name => name, - :ensure => :present + :gid => 123 ) - - comp = newcomp("groupmaker %s" % name, gobj) } + gobj.finish - trans = assert_events([:group_created], comp, "group") + trans = assert_events([:group_created], gobj, "group") assert(gobj.provider.exists?, "Did not create group") diff --git a/test/types/package.rb b/test/types/package.rb index 3cf1ea34c..611d73044 100755 --- a/test/types/package.rb +++ b/test/types/package.rb @@ -131,6 +131,8 @@ class TestPackages < Test::Unit::TestCase assert_nothing_raised { obj.retrieve } + + assert(obj.is(:ensure) != :absent, "Package %s is not installed" % obj.title) assert_instance_of(String, obj[:ensure], "Ensure did not return a version number") diff --git a/test/types/type.rb b/test/types/type.rb index 2438503c8..4be929ae9 100755 --- a/test/types/type.rb +++ b/test/types/type.rb @@ -798,6 +798,15 @@ end filetype[path] = one end end + + def test_ref + path = tempfile() + file = Puppet::Type.newfile(:path => path) + assert_equal("file[#{path}]", file.ref) + + exec = Puppet::Type.newexec(:title => "yay", :command => "/bin/echo yay") + assert_equal("exec[yay]", exec.ref) + end end # $Id$ |