From 8eddd4bcd23923a166e1ab7d81be1c1f2d341cdf Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 18 Mar 2007 19:25:15 +0000 Subject: More work on #542 -- services in noop now produce noop events so that they can themselves trigger further changes git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2295 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/other/transactions.rb | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/other/transactions.rb b/test/other/transactions.rb index d9451291e..a075a120e 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -4,6 +4,7 @@ $:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ require 'puppet' require 'puppettest' +require 'mocha' require 'puppettest/support/resources' # $Id$ @@ -1090,24 +1091,37 @@ class TestTransactions < Test::Unit::TestCase def test_noop_with_notify path = tempfile epath = tempfile - file = Puppet::Type.newfile(:path => path, :ensure => :file) + spath = tempfile + file = Puppet::Type.newfile(:path => path, :ensure => :file, + :title => "file") exec = Puppet::Type.type(:exec).create(:command => "touch %s" % epath, - :path => ENV["PATH"], :subscribe => file, :refreshonly => true) + :path => ENV["PATH"], :subscribe => file, :refreshonly => true, + :title => 'exec1') + exec2 = Puppet::Type.type(:exec).create(:command => "touch %s" % spath, + :path => ENV["PATH"], :subscribe => exec, :refreshonly => true, + :title => 'exec2') Puppet[:noop] = true assert(file.noop, "file not in noop") assert(exec.noop, "exec not in noop") - assert_apply(file, exec) + @logs.clear + assert_apply(file, exec, exec2) assert(! FileTest.exists?(path), "Created file in noop") assert(! FileTest.exists?(epath), "Executed exec in noop") - - logs = @logs.dup - assert_logged(:notice, /should be/, "did not log file change") - @logs = logs - assert_logged(:notice, /Would have triggered/, "did not log exec trigger") + assert(! FileTest.exists?(spath), "Executed second exec in noop") + + assert(@logs.detect { |l| + l.message =~ /should be/ and l.source == file.property(:ensure).path}, + "did not log file change") + assert(@logs.detect { |l| + l.message =~ /Would have/ and l.source == exec.path }, + "did not log first exec trigger") + assert(@logs.detect { |l| + l.message =~ /Would have/ and l.source == exec2.path }, + "did not log second exec trigger") end def test_only_stop_purging_with_relations -- cgit