summaryrefslogtreecommitdiffstats
path: root/test/network/handler
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-09 10:54:21 -0500
committerLuke Kanies <luke@madstop.com>2007-10-09 10:54:21 -0500
commit32753e11d9cd731760ec8ba3c4f1ad2e3402535e (patch)
tree0b6375bdefa041a7d4fbab9745ed084fb025bc30 /test/network/handler
parentafa1dee5eb3a8b5249715e61f9894b04ab34a6ae (diff)
parent01f132d8b88467dfd314ad355f1cdf9f546945b3 (diff)
downloadpuppet-32753e11d9cd731760ec8ba3c4f1ad2e3402535e.tar.gz
puppet-32753e11d9cd731760ec8ba3c4f1ad2e3402535e.tar.xz
puppet-32753e11d9cd731760ec8ba3c4f1ad2e3402535e.zip
Merge branch 'master' of git://michaelobrien.info/puppet into michael
Diffstat (limited to 'test/network/handler')
-rwxr-xr-xtest/network/handler/configuration.rb27
-rwxr-xr-xtest/network/handler/master.rb3
-rwxr-xr-xtest/network/handler/runner.rb11
3 files changed, 12 insertions, 29 deletions
diff --git a/test/network/handler/configuration.rb b/test/network/handler/configuration.rb
index 29a393769..1c08fd196 100755
--- a/test/network/handler/configuration.rb
+++ b/test/network/handler/configuration.rb
@@ -25,9 +25,7 @@ class TestHandlerConfiguration < Test::Unit::TestCase
config = Config.new
# First test the defaults
- args = {}
- config.instance_variable_set("@options", args)
- config.expects(:create_interpreter).with(args).returns(:interp)
+ config.expects(:create_interpreter).returns(:interp)
assert_equal(:interp, config.send(:interpreter), "Did not return the interpreter")
# Now run it again and make sure we get the same thing
@@ -39,20 +37,8 @@ class TestHandlerConfiguration < Test::Unit::TestCase
args = {}
# Try it first with defaults.
- Puppet::Parser::Interpreter.expects(:new).with(:Local => config.local?).returns(:interp)
- assert_equal(:interp, config.send(:create_interpreter, args), "Did not return the interpreter")
-
- # Now reset it and make sure a specified manifest passes through
- file = tempfile
- args[:Manifest] = file
- Puppet::Parser::Interpreter.expects(:new).with(:Local => config.local?, :Manifest => file).returns(:interp)
- assert_equal(:interp, config.send(:create_interpreter, args), "Did not return the interpreter")
-
- # And make sure the code does, too
- args.delete(:Manifest)
- args[:Code] = "yay"
- Puppet::Parser::Interpreter.expects(:new).with(:Local => config.local?, :Code => "yay").returns(:interp)
- assert_equal(:interp, config.send(:create_interpreter, args), "Did not return the interpreter")
+ Puppet::Parser::Interpreter.expects(:new).returns(:interp)
+ assert_equal(:interp, config.send(:create_interpreter), "Did not return the interpreter")
end
# Make sure node objects get appropriate data added to them.
@@ -67,7 +53,7 @@ class TestHandlerConfiguration < Test::Unit::TestCase
config.send(:add_node_data, fakenode)
# Now try it with classes.
- config.instance_variable_set("@options", {:Classes => %w{a b}})
+ config.classes = %w{a b}
list = []
fakenode = Object.new
fakenode.expects(:merge).with(:facts)
@@ -126,8 +112,9 @@ class TestHandlerConfiguration < Test::Unit::TestCase
# Now a non-local
config = Config.new(:Local => false)
- obj = Object.new
- yamld = Object.new
+ assert(! config.local?, "Config wrongly thinks it's local")
+ obj = mock 'dumpee'
+ yamld = mock 'yaml'
obj.expects(:to_yaml).with(:UseBlock => true).returns(yamld)
CGI.expects(:escape).with(yamld).returns(:translated)
assert_equal(:translated, config.send(:translate, obj), "Did not return translated config")
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index 42c4d22c9..6c4451d06 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -56,11 +56,10 @@ class TestMaster < Test::Unit::TestCase
@@tmpfiles << file2
client = master = nil
+ Puppet[:manifest] = manifest
assert_nothing_raised() {
# this is the default server setup
master = Puppet::Network::Handler.master.new(
- :Manifest => manifest,
- :UseNodes => false,
:Local => true
)
}
diff --git a/test/network/handler/runner.rb b/test/network/handler/runner.rb
index 23883a17c..50a00862a 100755
--- a/test/network/handler/runner.rb
+++ b/test/network/handler/runner.rb
@@ -7,15 +7,14 @@ require 'puppettest'
class TestHandlerRunner < Test::Unit::TestCase
include PuppetTest
- def mkclient(file)
+ def mkclient(code)
master = nil
client = nil
+ Puppet[:code] = code
# create our master
assert_nothing_raised() {
# this is the default server setup
master = Puppet::Network::Handler.master.new(
- :Manifest => file,
- :UseNodes => false,
:Local => true
)
}
@@ -38,8 +37,7 @@ class TestHandlerRunner < Test::Unit::TestCase
created = tempfile()
# We specify the schedule here, because I was having problems with
# using default schedules.
- File.open(file, "w") do |f|
- f.puts %{
+ code = %{
class yayness {
schedule { "yayness": period => weekly }
file { "#{created}": ensure => file, schedule => yayness }
@@ -47,9 +45,8 @@ class TestHandlerRunner < Test::Unit::TestCase
include yayness
}
- end
- client = mkclient(file)
+ client = mkclient(code)
runner = nil
assert_nothing_raised {