summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-05 19:24:44 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-05 19:24:44 +0000
commit06a7d345bef7a41cb6320e14a1dd9476505fd65f (patch)
tree7a30b6db252c332321d5f52a1d5b0e9ca9064831
parent2489764b12031f20022d08e662ee3fa826a75b95 (diff)
downloadpuppet-06a7d345bef7a41cb6320e14a1dd9476505fd65f.tar.gz
puppet-06a7d345bef7a41cb6320e14a1dd9476505fd65f.tar.xz
puppet-06a7d345bef7a41cb6320e14a1dd9476505fd65f.zip
Fixing ldap nodes -- they were always returning true because i was returning an empty array for missing nodes.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1733 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/parser/interpreter.rb6
-rwxr-xr-xtest/language/interpreter.rb18
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 111fe2ed3..60e449db6 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -438,6 +438,10 @@ class Puppet::Parser::Interpreter
classes.flatten!
+ if classes.empty?
+ classes = nil
+ end
+
return parent, classes
end
@@ -605,7 +609,7 @@ class Puppet::Parser::Interpreter
parent, classes = ldapsearch(node)
if parent or classes
args = {}
- args[:classes] = classes if classes and ! classes.empty?
+ args[:classes] = classes if classes
args[:parentnode] = parent if parent
return gennode(node, args)
else
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb
index e195e28b3..755a07aa8 100755
--- a/test/language/interpreter.rb
+++ b/test/language/interpreter.rb
@@ -151,9 +151,17 @@ class TestInterpreter < Test::Unit::TestCase
interp = mkinterp :NodeSources => [:ldap, :code]
- # Make sure we can find 'culain' in ldap
+ # Make sure we get nil and nil back when we search for something missing
parent, classes = nil
assert_nothing_raised do
+ parent, classes = interp.ldapsearch("nosuchhost")
+ end
+
+ assert_nil(parent, "Got a parent for a non-existent host")
+ assert_nil(classes, "Got classes for a non-existent host")
+
+ # Make sure we can find 'culain' in ldap
+ assert_nothing_raised do
parent, classes = interp.ldapsearch("culain")
end
@@ -173,6 +181,14 @@ class TestInterpreter < Test::Unit::TestCase
# culain uses basenode, so create that
basenode = interp.newnode([:basenode])[0]
+ # Make sure we get nothing for nonexistent hosts
+ none = nil
+ assert_nothing_raised do
+ none = interp.nodesearch_ldap("nosuchhost")
+ end
+
+ assert_nil(none, "Got a node for a non-existent host")
+
# Make sure we can find 'culain' in ldap
culain = nil
assert_nothing_raised do