summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-05 20:47:20 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-05 20:47:20 +0000
commitb8920939ade4d9956a7f3b2ba3a2c77a3f788c58 (patch)
treec0a78d5c5610c94968d8ca3b92715e1bbc7a7f21 /test
parent06a7d345bef7a41cb6320e14a1dd9476505fd65f (diff)
downloadpuppet-b8920939ade4d9956a7f3b2ba3a2c77a3f788c58.tar.gz
puppet-b8920939ade4d9956a7f3b2ba3a2c77a3f788c58.tar.xz
puppet-b8920939ade4d9956a7f3b2ba3a2c77a3f788c58.zip
Fixing weird case where the default node is in one node source and the real node is in a different one
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1734 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/interpreter.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb
index 755a07aa8..6f5b9cc68 100755
--- a/test/language/interpreter.rb
+++ b/test/language/interpreter.rb
@@ -249,13 +249,41 @@ class TestInterpreter < Test::Unit::TestCase
$stderr.puts "Not in madstop.com; skipping ldap tests"
end
+ # Test that node info and default node info in different sources isn't
+ # bad.
+ def test_multiple_nodesources
+
+ # Create another node source
+ Puppet::Parser::Interpreter.send(:define_method, :nodesearch_multi) do |*names|
+ if names[0] == "default"
+ gennode("default", {:facts => {}})
+ else
+ nil
+ end
+ end
+
+ interp = mkinterp :NodeSources => [:multi, :code]
+
+ interp.newnode(["node"])
+
+ obj = nil
+ assert_nothing_raised do
+ obj = interp.nodesearch("node")
+ end
+ assert(obj, "Did not find node")
+ assert_equal("node", obj.fqname)
+ end
+
# Make sure searchnode behaves as we expect.
def test_nodesearch
+ # We use two sources here to catch a weird bug where the default
+ # node is used if the host isn't in the first source.
interp = mkinterp
# Make some nodes
names = %w{node1 node2 node2.domain.com}
interp.newnode names
+ interp.newnode %w{default}
nodes = {}
# Make sure we can find them all, using the direct method
@@ -271,6 +299,13 @@ class TestInterpreter < Test::Unit::TestCase
assert(node, "Could not find #{name} via nodesearch")
end
+ # Make sure we find the default node when we search for nonexistent nodes
+ assert_nothing_raised do
+ default = interp.nodesearch("nosuchnode")
+ assert(default, "Did not find default node")
+ assert_equal("default", default.fqname)
+ end
+
# Now make sure the longest match always wins
node = interp.nodesearch(*%w{node2 node2.domain.com})