76
76
Puppet::Node::Facts.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b"))
79
it "should fail intelligently if it cannot find facts" do
80
Puppet::Node::Facts.expects(:find).with(@node.name).raises "foo"
81
lambda { @node.fact_merge }.should raise_error(Puppet::Error)
79
84
it "should prefer parameters already set on the node over facts from the node" do
80
85
@node.parameters = {"one" => "a"}
93
98
@node.merge "two" => "three"
94
99
@node.parameters["two"].should == "three"
102
it "should add the environment to the list of parameters" do
103
Puppet.settings.stubs(:value).with(:environments).returns("one,two")
104
Puppet.settings.stubs(:value).with(:environment).returns("one")
105
@node = Puppet::Node.new("testnode", :environment => "one")
106
@node.merge "two" => "three"
107
@node.parameters["environment"].should == "one"
110
it "should not set the environment if it is already set in the parameters" do
111
Puppet.settings.stubs(:value).with(:environments).returns("one,two")
112
Puppet.settings.stubs(:value).with(:environment).returns("one")
113
@node = Puppet::Node.new("testnode", :environment => "one")
114
@node.merge "environment" => "two"
115
@node.parameters["environment"].should == "two"
98
119
describe Puppet::Node, "when indirecting" do
126
147
@node.names.should be_instance_of(Array)
129
it "should have the node's fqdn as the second name" do
130
@node.names[1].should == "yay.domain.com"
133
it "should set the fqdn to the node's 'fqdn' fact if it is available" do
134
@node.parameters["fqdn"] = "boo.domain.com"
135
@node.names[1].should == "boo.domain.com"
138
it "should set the fqdn to the node's hostname and domain if no fqdn is available" do
139
@node.names[1].should == "yay.domain.com"
150
describe "and the node name is fully qualified" do
151
it "should contain an entry for each part of the node name" do
152
@node.names.should be_include("foo.domain.com")
153
@node.names.should be_include("foo.domain")
154
@node.names.should be_include("foo")
158
it "should include the node's fqdn" do
159
@node.names.should be_include("yay.domain.com")
162
it "should combine and include the node's hostname and domain if no fqdn is available" do
163
@node.names.should be_include("yay.domain.com")
142
166
it "should contain an entry for each name available by stripping a segment of the fqdn" do
143
167
@node.parameters["fqdn"] = "foo.deep.sub.domain.com"
144
@node.names[2].should == "foo.deep.sub.domain"
145
@node.names[3].should == "foo.deep.sub"
168
@node.names.should be_include("foo.deep.sub.domain")
169
@node.names.should be_include("foo.deep.sub")
148
172
describe "and :node_name is set to 'cert'" do
174
Puppet.settings.stubs(:value).with(:strict_hostname_checking).returns false
150
175
Puppet.settings.stubs(:value).with(:node_name).returns "cert"
153
178
it "should use the passed-in key as the first value" do
154
179
@node.names[0].should == "foo.domain.com"
182
describe "and strict hostname checking is enabled" do
183
it "should only use the passed-in key" do
184
Puppet.settings.expects(:value).with(:strict_hostname_checking).returns true
185
@node.names.should == ["foo.domain.com"]
158
190
describe "and :node_name is set to 'facter'" do
192
Puppet.settings.stubs(:value).with(:strict_hostname_checking).returns false
160
193
Puppet.settings.stubs(:value).with(:node_name).returns "facter"