summaryrefslogtreecommitdiffstats
path: root/test/other/events.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-22 22:27:20 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-22 22:27:20 +0000
commitf7328804d00d8a82d7ab3a955ff579ff956ef3d0 (patch)
tree7a6d5119dea6a6309675120fd99f5cc023ad644a /test/other/events.rb
parent8fe558cca075ab85619a73f4a80408de58810ef7 (diff)
downloadpuppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.tar.gz
puppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.tar.xz
puppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.zip
Getting rid of the tc_ prefix to test cases
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@724 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/other/events.rb')
-rwxr-xr-xtest/other/events.rb111
1 files changed, 111 insertions, 0 deletions
diff --git a/test/other/events.rb b/test/other/events.rb
new file mode 100755
index 000000000..61551983e
--- /dev/null
+++ b/test/other/events.rb
@@ -0,0 +1,111 @@
+if __FILE__ == $0
+ $:.unshift '..'
+ $:.unshift '../../lib'
+ $puppetbase = "../../../../language/trunk"
+end
+
+require 'puppet'
+require 'puppettest'
+require 'test/unit'
+
+# $Id$
+
+class TestEvents < Test::Unit::TestCase
+ include TestPuppet
+ def teardown
+ super
+ Puppet::Event::Subscription.clear
+ end
+
+ def test_simplesubscribe
+ file = Puppet::Type::PFile.create(
+ :name => "/tmp/eventtestingA",
+ :create => true
+ )
+ exec = Puppet::Type::Exec.create(
+ :name => "echo true",
+ :path => "/usr/bin:/bin",
+ :refreshonly => true,
+ :subscribe => [[file.class.name, file.name]]
+ )
+
+ @@tmpfiles << "/tmp/eventtestingA"
+
+ comp = newcomp("eventtesting", file, exec)
+
+ trans = assert_events(comp, [:file_created], "events")
+
+ assert_equal(1, trans.triggered?(exec, :refresh))
+ end
+
+ def test_simplerequire
+ file = Puppet::Type::PFile.create(
+ :name => "/tmp/eventtestingA",
+ :create => true
+ )
+ exec = Puppet::Type::Exec.create(
+ :name => "echo true",
+ :path => "/usr/bin:/bin",
+ :refreshonly => true,
+ :require => [[file.class.name, file.name]]
+ )
+
+ @@tmpfiles << "/tmp/eventtestingA"
+
+ comp = Puppet::Type::Component.create(
+ :name => "eventtesting"
+ )
+ comp.push exec
+ trans = comp.evaluate
+ events = nil
+ assert_nothing_raised {
+ events = trans.evaluate
+ }
+
+ assert_equal(1, events.length)
+
+ assert_equal(0, trans.triggered?(exec, :refresh))
+ end
+
+ def test_zladderrequire
+ comps = {}
+ objects = {}
+ fname = "/tmp/eventtestfuntest"
+ [:a, :b].each { |l|
+ case l
+ when :a
+ name = "/tmp/eventtesting%s" % l
+ objects[l] = Puppet::Type::PFile.create(
+ :name => name,
+ :create => true
+ )
+ @@tmpfiles << name
+ when :b
+ objects[l] = Puppet::Type::Exec.create(
+ :name => "touch %s" % fname,
+ :path => "/usr/bin:/bin",
+ :refreshonly => true
+ )
+ @@tmpfiles << fname
+ end
+
+
+ comps[l] = Puppet::Type::Component.create(
+ :name => "eventtesting%s" % l
+ )
+
+ comps[l].push objects[l]
+ }
+
+ comps[:b][:subscribe] = [[comps[:a].class.name, comps[:a].name]]
+
+ trans = comps[:a].evaluate
+ events = nil
+ assert_nothing_raised {
+ events = trans.evaluate
+ }
+
+ assert(FileTest.exists?(fname))
+ #assert_equal(events.length, trans.triggered?(objects[:b], :refresh))
+ end
+end