diff options
| author | Luke Kanies <luke@madstop.com> | 2008-06-15 20:21:51 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-06-15 20:21:51 -0500 |
| commit | 6b69a86e48be082a6d03ce69f2700c4c874e222f (patch) | |
| tree | f80f431aac5ada885d7b8d084b31a4cfe5cc70a0 /spec/unit/node.rb | |
| parent | c542dc065fd618ae85bb6e8960d8819f42aefaeb (diff) | |
| parent | d3a4d9ad72ae12199163864582bfbb0f30a7f271 (diff) | |
| download | puppet-6b69a86e48be082a6d03ce69f2700c4c874e222f.tar.gz puppet-6b69a86e48be082a6d03ce69f2700c4c874e222f.tar.xz puppet-6b69a86e48be082a6d03ce69f2700c4c874e222f.zip | |
Merge branch '0.24.x'
Conflicts:
CHANGELOG
Finally adding release names to the changelog so we can keep the changes aligned in the right part of the log.
Diffstat (limited to 'spec/unit/node.rb')
| -rwxr-xr-x | spec/unit/node.rb | 76 |
1 files changed, 12 insertions, 64 deletions
diff --git a/spec/unit/node.rb b/spec/unit/node.rb index 4a41dadf9..70aa8bd9a 100755 --- a/spec/unit/node.rb +++ b/spec/unit/node.rb @@ -54,11 +54,6 @@ describe Puppet::Node, "when initializing" do Puppet.settings.stubs(:value).with(:environments).returns("myenv") proc { Puppet::Node.new("testing", :environment => "other") }.should raise_error(ArgumentError) end - - it "should accept names passed in" do - @node = Puppet::Node.new("testing", :names => ["myenv"]) - @node.names.should == ["myenv"] - end end describe Puppet::Node, "when returning the environment" do @@ -152,42 +147,33 @@ describe Puppet::Node, "when indirecting" do end end -describe Puppet::Node do - # LAK:NOTE This is used to keep track of when a given node has connected, - # so we can report on nodes that do not appear to connecting to the - # central server. - it "should provide a method for noting that the node has connected" -end - describe Puppet::Node, "when generating the list of names to search through" do before do - @facts = Puppet::Node::Facts.new("foo", "hostname" => "yay", "domain" => "domain.com") - @node = Puppet::Node.new("foo") - - Puppet::Node.stubs(:node_facts).returns @facts.values + @node = Puppet::Node.new("foo.domain.com") + @node.parameters = {"hostname" => "yay", "domain" => "domain.com"} end it "should return an array of names" do - Puppet::Node.node_names("foo").should be_instance_of(Array) + @node.names.should be_instance_of(Array) end it "should have the node's fqdn as the second name" do - Puppet::Node.node_names("foo.domain.com")[1].should == "yay.domain.com" + @node.names[1].should == "yay.domain.com" end it "should set the fqdn to the node's 'fqdn' fact if it is available" do - @facts.values["fqdn"] = "boo.domain.com" - Puppet::Node.node_names("foo")[1].should == "boo.domain.com" + @node.parameters["fqdn"] = "boo.domain.com" + @node.names[1].should == "boo.domain.com" end it "should set the fqdn to the node's hostname and domain if no fqdn is available" do - Puppet::Node.node_names("foo")[1].should == "yay.domain.com" + @node.names[1].should == "yay.domain.com" end it "should contain an entry for each name available by stripping a segment of the fqdn" do - @facts.values["fqdn"] = "foo.deep.sub.domain.com" - Puppet::Node.node_names("foo")[2].should == "foo.deep.sub.domain" - Puppet::Node.node_names("foo")[3].should == "foo.deep.sub" + @node.parameters["fqdn"] = "foo.deep.sub.domain.com" + @node.names[2].should == "foo.deep.sub.domain" + @node.names[3].should == "foo.deep.sub" end describe "and :node_name is set to 'cert'" do @@ -196,7 +182,7 @@ describe Puppet::Node, "when generating the list of names to search through" do end it "should use the passed-in key as the first value" do - Puppet::Node.node_names("foo")[0].should == "foo" + @node.names[0].should == "foo.domain.com" end end @@ -206,45 +192,7 @@ describe Puppet::Node, "when generating the list of names to search through" do end it "should use the node's 'hostname' fact as the first value" do - Puppet::Node.node_names("foo")[0].should == "yay" + @node.names[0].should == "yay" end end end - -describe Puppet::Node, "when searching for nodes" do - before do - @facts = Puppet::Node::Facts.new("foo", "hostname" => "yay", "domain" => "domain.com") - @node = Puppet::Node.new("foo") - Puppet::Node::Facts.stubs(:find).with("foo").returns(@facts) - end - - it "should use the 'node_names' method to get its list of names to search" do - Puppet::Node.expects(:node_names).with{ |*args| args[0] == "foo" }.returns %w{a b} - Puppet::Node.stubs(:find) - Puppet::Node.find_by_any_name("foo") - end - - it "should return the first node found using the generated list of names" do - Puppet::Node.expects(:node_names).returns %w{a b} - Puppet::Node.expects(:find).with("a").returns(nil) - Puppet::Node.expects(:find).with("b").returns(@node) - Puppet::Node.find_by_any_name("foo").should equal(@node) - end - - it "should attempt to find a default node if no names are found" do - names = [] - Puppet::Node.stubs(:find).with do |name| - names << name - end.returns(nil) - Puppet::Node.find_by_any_name("foo") - names[-1].should == "default" - end - - it "should set the node name to the provided key" do - Puppet::Node.stubs(:node_names).returns %w{a b} - Puppet::Node.stubs(:find).returns @node - - @node.expects(:name=).with("foo") - Puppet::Node.find_by_any_name("foo") - end -end |
