summaryrefslogtreecommitdiffstats
path: root/spec/unit/indirector/node
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-02 22:03:45 -0500
committerLuke Kanies <luke@madstop.com>2008-07-02 22:03:45 -0500
commitc825c991fd68274ae1b172f97059be616d5b057e (patch)
treecfa8e7e6bff3c0c85ce0340b344f8d6ffde912bc /spec/unit/indirector/node
parentdaf0d9db5dc400a9795a5f741c8c63184f5e8982 (diff)
downloadpuppet-c825c991fd68274ae1b172f97059be616d5b057e.tar.gz
puppet-c825c991fd68274ae1b172f97059be616d5b057e.tar.xz
puppet-c825c991fd68274ae1b172f97059be616d5b057e.zip
Fixing the ldap node terminus to merge facts with the right name.
Previously, I was merging early and changing the name later. This commit fixes it so that the node is created with the right name in the first place, so the node.fact_merge actually works. Yay for real-world testing. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/indirector/node')
-rwxr-xr-xspec/unit/indirector/node/ldap.rb36
1 files changed, 33 insertions, 3 deletions
diff --git a/spec/unit/indirector/node/ldap.rb b/spec/unit/indirector/node/ldap.rb
index 01d148631..ed8809e73 100755
--- a/spec/unit/indirector/node/ldap.rb
+++ b/spec/unit/indirector/node/ldap.rb
@@ -136,6 +136,14 @@ describe Puppet::Node::Ldap do
@searcher.stubs(:name2hash).returns @result
end
+ it "should create the node with the correct name, even if it was found by a different name" do
+ @searcher.expects(:name2hash).with("mynode.domain.com").returns nil
+ @searcher.expects(:name2hash).with("mynode").returns @result
+
+ Puppet::Node.expects(:new).with("mynode.domain.com").returns @node
+ @searcher.find(@request)
+ end
+
it "should add any classes from ldap" do
@result[:classes] = %w[a b c d]
@node.expects(:classes=).with(%w{a b c d})
@@ -161,6 +169,19 @@ describe Puppet::Node::Ldap do
@searcher.find(@request)
end
+ it "should merge the node's facts after the parameters from ldap are assigned" do
+ # Make sure we've got data to start with, so the parameters are actually set.
+ @result[:parameters] = {}
+ @result[:parameters]["one"] = "yay"
+
+ # A hackish way to enforce order.
+ set = false
+ @node.expects(:parameters=).with { |*args| set = true }
+ @node.expects(:fact_merge).with { |*args| raise "Facts were merged before parameters were set" unless set; true }
+
+ @searcher.find(@request)
+ end
+
describe "and a parent node is specified" do
before do
@entry = {:classes => [], :parameters => {}}
@@ -304,13 +325,22 @@ describe Puppet::Node::Ldap do
@searcher.search @request
end
- it "should return a node for each processed entry" do
- @searcher.expects(:ldapsearch).yields("one")
- @searcher.expects(:entry2hash).with("one").returns(:name => "foo")
+ it "should return a node for each processed entry with the name from the entry" do
+ @searcher.expects(:ldapsearch).yields("whatever")
+ @searcher.expects(:entry2hash).with("whatever").returns(:name => "foo")
result = @searcher.search(@request)
result[0].should be_instance_of(Puppet::Node)
result[0].name.should == "foo"
end
+
+ it "should merge each node's facts" do
+ node = mock 'node'
+ Puppet::Node.expects(:new).with("foo").returns node
+ node.expects(:fact_merge)
+ @searcher.stubs(:ldapsearch).yields("one")
+ @searcher.stubs(:entry2hash).with("one").returns(:name => "foo")
+ @searcher.search(@request)
+ end
end
end