diff options
author | Luke Kanies <luke@madstop.com> | 2007-11-20 01:08:34 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-11-20 01:08:34 -0600 |
commit | 8cc07adda20b4e63bbad5b2759303d00d215341c (patch) | |
tree | e8157ba56cabb51ba67d9eb8d355a40ef4e96c4c /spec/unit/node | |
parent | 53008e567fd64f391e0b45652b2f4ac1551ccf47 (diff) | |
download | puppet-8cc07adda20b4e63bbad5b2759303d00d215341c.tar.gz puppet-8cc07adda20b4e63bbad5b2759303d00d215341c.tar.xz puppet-8cc07adda20b4e63bbad5b2759303d00d215341c.zip |
Using the Environment class to determine the default environment,
rather than plenty of different places having the logic of how
to determine the default environment.
Diffstat (limited to 'spec/unit/node')
-rwxr-xr-x | spec/unit/node/environment.rb | 4 | ||||
-rwxr-xr-x | spec/unit/node/node.rb | 136 |
2 files changed, 4 insertions, 136 deletions
diff --git a/spec/unit/node/environment.rb b/spec/unit/node/environment.rb index 69d7acb47..8433a9877 100755 --- a/spec/unit/node/environment.rb +++ b/spec/unit/node/environment.rb @@ -55,6 +55,10 @@ describe Puppet::Node::Environment do proc { Puppet::Node::Environment.new("three") }.should raise_error(ArgumentError) end + it "should consider environments that are empty strings invalid" do + Puppet::Node::Environment.valid?("").should be_false + end + it "should fail if a no-longer-valid environment instance is asked for" do Puppet.settings.expects(:value).with(:environments).returns("one") Puppet::Node::Environment.new("one") diff --git a/spec/unit/node/node.rb b/spec/unit/node/node.rb deleted file mode 100755 index 06719c4cd..000000000 --- a/spec/unit/node/node.rb +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../spec_helper' - -describe Puppet::Node, " when initializing" do - before do - @node = Puppet::Node.new("testnode") - end - - it "should set the node name" do - @node.name.should == "testnode" - end - - it "should not allow nil node names" do - proc { Puppet::Node.new(nil) }.should raise_error(ArgumentError) - end - - it "should default to an empty parameter hash" do - @node.parameters.should == {} - end - - it "should default to an empty class array" do - @node.classes.should == [] - end - - it "should note its creation time" do - @node.time.should be_instance_of(Time) - end - - it "should accept parameters passed in during initialization" do - params = {"a" => "b"} - @node = Puppet::Node.new("testing", :parameters => params) - @node.parameters.should == params - end - - it "should accept classes passed in during initialization" do - classes = %w{one two} - @node = Puppet::Node.new("testing", :classes => classes) - @node.classes.should == classes - end - - it "should always return classes as an array" do - @node = Puppet::Node.new("testing", :classes => "myclass") - @node.classes.should == ["myclass"] - end - - it "should accept the environment during initialization" do - @node = Puppet::Node.new("testing", :environment => "myenv") - @node.environment.should == "myenv" - 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 - before do - @node = Puppet::Node.new("testnode") - end - - it "should return the 'environment' fact if present and there is no explicit environment" do - @node.parameters = {"environment" => "myenv"} - @node.environment.should == "myenv" - end - - it "should return the central environment if there is no environment fact nor explicit environment" do - Puppet.settings.expects(:[]).with(:environment).returns(:centralenv) - @node.environment.should == :centralenv - end - - it "should not use an explicit environment that is an empty string" do - @node.environment == "" - @node.environment.should be_nil - end - - it "should not use an environment fact that is an empty string" do - @node.parameters = {"environment" => ""} - @node.environment.should be_nil - end - - it "should not use an explicit environment that is an empty string" do - Puppet.settings.expects(:[]).with(:environment).returns(nil) - @node.environment.should be_nil - end -end - -describe Puppet::Node, " when merging facts" do - before do - @node = Puppet::Node.new("testnode") - Puppet::Node::Facts.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b")) - end - - it "should prefer parameters already set on the node over facts from the node" do - @node.parameters = {"one" => "a"} - @node.fact_merge - @node.parameters["one"].should == "a" - end - - it "should add passed parameters to the parameter list" do - @node.parameters = {"one" => "a"} - @node.fact_merge - @node.parameters["two"].should == "b" - end - - it "should accept arbitrary parameters to merge into its parameters" do - @node.parameters = {"one" => "a"} - @node.merge "two" => "three" - @node.parameters["two"].should == "three" - end -end - -describe Puppet::Node, " when indirecting" do - it "should redirect to the indirection" do - @indirection = mock 'indirection' - Puppet::Node.stubs(:indirection).returns(@indirection) - @indirection.expects(:find).with(:my_node.to_s) - Puppet::Node.find(:my_node.to_s) - end - - it "should default to the 'null' node terminus" do - Puppet::Node.indirection.terminus_class.should == :null - end - - after do - Puppet::Indirector::Indirection.clear_cache - 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 |