diff options
| author | Luke Kanies <luke@madstop.com> | 2007-08-22 17:57:28 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-08-22 17:57:28 -0500 |
| commit | 8b3361afae35cfb65754d7bd9aff5b820ed714f0 (patch) | |
| tree | 0a6fe8ce4029a8ea8bb82ab80dfb57cb5b6c20cc /test | |
| parent | f1727f18ab933df9ecbecc2da8fad72eb441e0d5 (diff) | |
| download | puppet-8b3361afae35cfb65754d7bd9aff5b820ed714f0.tar.gz puppet-8b3361afae35cfb65754d7bd9aff5b820ed714f0.tar.xz puppet-8b3361afae35cfb65754d7bd9aff5b820ed714f0.zip | |
The last commits before I actually start on the multi-environment support. There are still failing tests, but apparently only those that are also failing in trunk.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/configuration.rb | 2 | ||||
| -rwxr-xr-x | test/network/handler/node.rb | 68 | ||||
| -rwxr-xr-x | test/network/xmlrpc/processor.rb | 2 | ||||
| -rwxr-xr-x | test/other/node.rb | 75 |
4 files changed, 78 insertions, 69 deletions
diff --git a/test/language/configuration.rb b/test/language/configuration.rb index fbdf68e73..a17b5a7ae 100755 --- a/test/language/configuration.rb +++ b/test/language/configuration.rb @@ -15,7 +15,7 @@ class TestConfiguration < Test::Unit::TestCase Config = Puppet::Parser::Configuration Scope = Puppet::Parser::Scope Node = Puppet::Network::Handler.handler(:node) - SimpleNode = Node::SimpleNode + SimpleNode = Puppet::Node def mknode(name = "foo") @node = SimpleNode.new(name) diff --git a/test/network/handler/node.rb b/test/network/handler/node.rb index 745c7470e..d5c98fec6 100755 --- a/test/network/handler/node.rb +++ b/test/network/handler/node.rb @@ -12,7 +12,7 @@ require 'puppet/network/handler/node' module NodeTesting include PuppetTest Node = Puppet::Network::Handler::Node - SimpleNode = Puppet::Network::Handler::Node::SimpleNode + SimpleNode = Puppet::Node def mk_node_mapper # First, make sure our nodesearch command works as we expect @@ -342,72 +342,6 @@ class TestNodeHandler < Test::Unit::TestCase end end -class TestSimpleNode < Test::Unit::TestCase - include NodeTesting - - # Make sure we get all the defaults correctly. - def test_simplenode_initialize - node = nil - assert_nothing_raised("could not create a node without classes or parameters") do - node = SimpleNode.new("testing") - end - assert_equal("testing", node.name, "Did not set name correctly") - assert_equal({}, node.parameters, "Node parameters did not default correctly") - assert_equal([], node.classes, "Node classes did not default correctly") - assert_instance_of(Time, node.time, "Did not set the creation time") - - # Now test it with values for both - params = {"a" => "b"} - classes = %w{one two} - assert_nothing_raised("could not create a node with classes and parameters") do - node = SimpleNode.new("testing", :parameters => params, :classes => classes) - end - assert_equal("testing", node.name, "Did not set name correctly") - assert_equal(params, node.parameters, "Node parameters did not get set correctly") - assert_equal(classes, node.classes, "Node classes did not get set correctly") - - # And make sure a single class gets turned into an array - assert_nothing_raised("could not create a node with a class as a string") do - node = SimpleNode.new("testing", :classes => "test") - end - assert_equal(%w{test}, node.classes, "A node class string was not converted to an array") - - # Make sure we get environments - assert_nothing_raised("could not create a node with an environment") do - node = SimpleNode.new("testing", :environment => "test") - end - assert_equal("test", node.environment, "Environment was not set") - - # Now make sure we get the default env - Puppet[:environment] = "prod" - assert_nothing_raised("could not create a node with no environment") do - node = SimpleNode.new("testing") - end - assert_equal("prod", node.environment, "Did not get default environment") - - # But that it stays nil if there's no default env set - Puppet[:environment] = "" - assert_nothing_raised("could not create a node with no environment and no default env") do - node = SimpleNode.new("testing") - end - assert_nil(node.environment, "Got a default env when none was set") - - end - - # Verify that the node source wins over facter. - def test_fact_merge - node = SimpleNode.new("yay", :parameters => {"a" => "one", "b" => "two"}) - - assert_nothing_raised("Could not merge parameters") do - node.fact_merge("b" => "three", "c" => "yay") - end - params = node.parameters - assert_equal("one", params["a"], "Lost nodesource parameters in parameter merge") - assert_equal("two", params["b"], "Overrode nodesource parameters in parameter merge") - assert_equal("yay", params["c"], "Did not get facts in parameter merge") - end -end - # Test our configuration object. class TestNodeSources < Test::Unit::TestCase include NodeTesting diff --git a/test/network/xmlrpc/processor.rb b/test/network/xmlrpc/processor.rb index 101d268b2..6808d0100 100755 --- a/test/network/xmlrpc/processor.rb +++ b/test/network/xmlrpc/processor.rb @@ -64,7 +64,7 @@ class TestXMLRPCProcessor < Test::Unit::TestCase request.expects(:handler=).with("myhandler") request.expects(:method=).with("mymethod") - @processor.expects(:verify).times(2) + @processor.stubs(:verify) @processor.expects(:handle).with(request.call, "params", request.name, request.ip) diff --git a/test/other/node.rb b/test/other/node.rb new file mode 100755 index 000000000..b3f12d11d --- /dev/null +++ b/test/other/node.rb @@ -0,0 +1,75 @@ +#!/usr/bin/env ruby + +$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ + +require 'mocha' +require 'puppettest' +require 'puppet/node' + +class TestNode < Test::Unit::TestCase + include PuppetTest + Node = Puppet::Node + + # Make sure we get all the defaults correctly. + def test_initialize + node = nil + assert_nothing_raised("could not create a node without classes or parameters") do + node = Node.new("testing") + end + assert_equal("testing", node.name, "Did not set name correctly") + assert_equal({}, node.parameters, "Node parameters did not default correctly") + assert_equal([], node.classes, "Node classes did not default correctly") + assert_instance_of(Time, node.time, "Did not set the creation time") + + # Now test it with values for both + params = {"a" => "b"} + classes = %w{one two} + assert_nothing_raised("could not create a node with classes and parameters") do + node = Node.new("testing", :parameters => params, :classes => classes) + end + assert_equal("testing", node.name, "Did not set name correctly") + assert_equal(params, node.parameters, "Node parameters did not get set correctly") + assert_equal(classes, node.classes, "Node classes did not get set correctly") + + # And make sure a single class gets turned into an array + assert_nothing_raised("could not create a node with a class as a string") do + node = Node.new("testing", :classes => "test") + end + assert_equal(%w{test}, node.classes, "A node class string was not converted to an array") + + # Make sure we get environments + assert_nothing_raised("could not create a node with an environment") do + node = Node.new("testing", :environment => "test") + end + assert_equal("test", node.environment, "Environment was not set") + + # Now make sure we get the default env + Puppet[:environment] = "prod" + assert_nothing_raised("could not create a node with no environment") do + node = Node.new("testing") + end + assert_equal("prod", node.environment, "Did not get default environment") + + # But that it stays nil if there's no default env set + Puppet[:environment] = "" + assert_nothing_raised("could not create a node with no environment and no default env") do + node = Node.new("testing") + end + assert_nil(node.environment, "Got a default env when none was set") + + end + + # Verify that the node source wins over facter. + def test_fact_merge + node = Node.new("yay", :parameters => {"a" => "one", "b" => "two"}) + + assert_nothing_raised("Could not merge parameters") do + node.fact_merge("b" => "three", "c" => "yay") + end + params = node.parameters + assert_equal("one", params["a"], "Lost nodesource parameters in parameter merge") + assert_equal("two", params["b"], "Overrode nodesource parameters in parameter merge") + assert_equal("yay", params["c"], "Did not get facts in parameter merge") + end +end + |
