summaryrefslogtreecommitdiffstats
path: root/test/network/handler/runner.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-12 22:08:44 -0600
committerLuke Kanies <luke@madstop.com>2007-11-12 22:08:44 -0600
commit72510bfaa65e97f4eaaf246ef8f1c155716967b6 (patch)
tree978aa0e92812f5854978048162c6e2ab752dad72 /test/network/handler/runner.rb
parentdd7caa76e160ed51c8b0e123c18f7526b575bfec (diff)
downloadpuppet-72510bfaa65e97f4eaaf246ef8f1c155716967b6.tar.gz
puppet-72510bfaa65e97f4eaaf246ef8f1c155716967b6.tar.xz
puppet-72510bfaa65e97f4eaaf246ef8f1c155716967b6.zip
Fixing #800 by refactoring how configurations are retrieved
from the server. The real problem was getting all of the validation done before any caching, which required a good bit more refactoring than I expected. In actuality, this commit is relatively small even though it covers many files; most of the changes just make the code clearer or shorter.
Diffstat (limited to 'test/network/handler/runner.rb')
-rwxr-xr-xtest/network/handler/runner.rb72
1 files changed, 19 insertions, 53 deletions
diff --git a/test/network/handler/runner.rb b/test/network/handler/runner.rb
index 402b27ffc..171458ffa 100755
--- a/test/network/handler/runner.rb
+++ b/test/network/handler/runner.rb
@@ -29,7 +29,8 @@ class TestHandlerRunner < Test::Unit::TestCase
client
end
- def test_runner
+ def setup
+ super
FileUtils.mkdir_p(Puppet[:statedir])
Puppet[:ignoreschedules] = false
# Okay, make our manifest
@@ -37,7 +38,7 @@ class TestHandlerRunner < Test::Unit::TestCase
created = tempfile()
# We specify the schedule here, because I was having problems with
# using default schedules.
- code = %{
+ @code = %{
class yayness {
schedule { "yayness": period => weekly }
file { "#{created}": ensure => file, schedule => yayness }
@@ -46,59 +47,24 @@ class TestHandlerRunner < Test::Unit::TestCase
include yayness
}
- client = mkclient(code)
+ @client = mkclient(@code)
- runner = nil
- assert_nothing_raised {
- runner = Puppet::Network::Handler.runner.new
- }
- # First: tags
- # Second: ignore schedules true/false
- # Third: background true/false
- # Fourth: whether file should exist true/false
- [
- ["with no backgrounding",
- nil, true, true, true],
- ["in the background",
- nil, true, false, true],
- ["with a bad tag",
- ["coolness"], true, false, false],
- ["with another bad tag",
- "coolness", true, false, false],
- ["with a good tag",
- ["coolness", "yayness"], true, false, true],
- ["with another good tag",
- ["yayness"], true, false, true],
- ["with a third good tag",
- "yayness", true, false, true],
- ["with no tags",
- "", true, false, true],
- ["not ignoring schedules",
- nil, false, false, false],
- ["ignoring schedules",
- nil, true, false, true],
- ].each do |msg, tags, ignore, fg, shouldexist|
- if FileTest.exists?(created)
- File.unlink(created)
- end
- assert_nothing_raised {
- # Try it without backgrounding
- runner.run(tags, ignore, fg)
- }
+ @runner = Puppet::Network::Handler.runner.new
+ end
+
+ def test_runner_when_in_foreground
+ @client.expects(:run).with(:tags => "mytags", :ignoreschedules => true)
+
+ Process.expects(:newthread).never
- unless fg
- Puppet.join
- end
-
- if shouldexist
- assert(FileTest.exists?(created), "File did not get created " +
- msg)
- else
- assert(!FileTest.exists?(created), "File got created incorrectly " +
- msg)
- end
- end
+ @runner.run("mytags", true, true)
end
-end
+ def test_runner_when_in_background
+ @client.expects(:run).with(:tags => "mytags", :ignoreschedules => true)
+
+ Puppet.expects(:newthread).yields
+ @runner.run("mytags", true, false)
+ end
+end