diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-08-12 13:53:13 -0700 |
---|---|---|
committer | Jesse Wolfe <jes5199@gmail.com> | 2010-08-12 13:53:29 -0700 |
commit | 1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac (patch) | |
tree | 3c6495838d1b876528cb4522de3484c44749140d /spec/unit/parser/functions | |
parent | d5db8db116aff58215ab0feebd7ec02086040f51 (diff) | |
parent | 0f56c1b02d40f1f8552d933dd78b24745937b137 (diff) | |
download | puppet-1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac.tar.gz puppet-1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac.tar.xz puppet-1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac.zip |
Merge branch 'next'
This synchronizes the 2.7 master branch with 2.6.1RC2
Diffstat (limited to 'spec/unit/parser/functions')
-rwxr-xr-x | spec/unit/parser/functions/extlookup_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/parser/functions/include_spec.rb | 22 | ||||
-rwxr-xr-x | spec/unit/parser/functions/require_spec.rb | 2 | ||||
-rwxr-xr-x | spec/unit/parser/functions/tag_spec.rb | 1 |
4 files changed, 15 insertions, 26 deletions
diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb index bf2880345..a3dcaa742 100755 --- a/spec/unit/parser/functions/extlookup_spec.rb +++ b/spec/unit/parser/functions/extlookup_spec.rb @@ -7,8 +7,9 @@ describe "the extlookup function" do before :each do @scope = Puppet::Parser::Scope.new - + @scope.stubs(:environment).returns(Puppet::Node::Environment.new('production')) + Puppet::Parser::Functions.function("extlookup") end it "should exist" do @@ -62,9 +63,8 @@ describe "the extlookup function" do end describe "should look in $extlookup_datadir for data files listed by $extlookup_precedence" do - before do + before do @scope.stubs(:lookupvar).with('extlookup_datadir').returns("/tmp") - @scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"]) File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" } File.open("/tmp/two.csv","w") do |two| two.puts "key,value2" @@ -73,13 +73,23 @@ describe "the extlookup function" do end it "when the key is in the first file" do + @scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"]) result = @scope.function_extlookup([ "key" ]) result.should == "value1" end it "when the key is in the second file" do + @scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"]) result = @scope.function_extlookup([ "key2" ]) result.should == "value_two" end + + it "should not modify extlookup_precedence data" do + variable = '%{fqdn}' + @scope.stubs(:lookupvar).with('extlookup_precedence').returns([variable,"one"]) + @scope.stubs(:lookupvar).with('fqdn').returns('myfqdn') + result = @scope.function_extlookup([ "key" ]) + variable.should == '%{fqdn}' + end end end diff --git a/spec/unit/parser/functions/include_spec.rb b/spec/unit/parser/functions/include_spec.rb index e5f051906..4f609b055 100644 --- a/spec/unit/parser/functions/include_spec.rb +++ b/spec/unit/parser/functions/include_spec.rb @@ -8,10 +8,6 @@ describe "the 'include' function" do Puppet::Node::Environment.stubs(:current).returns(nil) @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo")) @scope = Puppet::Parser::Scope.new(:compiler => @compiler) - # MQR TODO: Without the following stub these tests cause hundreds of spurious errors in - # subsequent tests. With it, there are no spurious failures and all but one - # of the tests (marked pending, bellow) fail. This needs a better solution. - Puppet::Parser::Resource.stubs(:new).with('stage', :main, :scope => @scope).returns 'foo' end it "should exist" do @@ -34,22 +30,4 @@ describe "the 'include' function" do @compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| lazy == false}.returns("foo") @scope.function_include("foo") end - - it "should allow a parent to include its child" do - pending "Resolution of MQR TODO item, above" - @parent_type = Puppet::Resource::Type.new(:hostclass, "parent") - @parent_resource = Puppet::Parser::Resource.new(:hostclass, "parent", :scope => @scope) - @subscope = @parent_type.subscope(@scope,@parent_resource) - @scope.environment.known_resource_types.stubs(:find_hostclass).with{|nses,name| name.downcase == "parent"}.returns(@parent_type) - - @type = Puppet::Resource::Type.new(:hostclass, "foo") - @type.stubs(:parent_scope).returns(@subscope) - @type.parent = "parent" - @resource = Puppet::Parser::Resource.new(:hostclass, "foo", :scope => @subscope) - @resource.stubs(:resource_type).returns(@type) - @scope.environment.known_resource_types.stubs(:find_hostclass).with{|nses,name| name.downcase == "foo"}.returns(@parent_type) - Puppet::Resource.stubs(:new).returns(@resource) - Puppet::Parser::Resource.stubs(:new).returns(@resource) - lambda { @subscope.function_include("foo") }.should_not raise_error - end end diff --git a/spec/unit/parser/functions/require_spec.rb b/spec/unit/parser/functions/require_spec.rb index bd42fa579..49c4bbf74 100755 --- a/spec/unit/parser/functions/require_spec.rb +++ b/spec/unit/parser/functions/require_spec.rb @@ -6,7 +6,7 @@ describe "the require function" do before :each do @catalog = stub 'catalog' - @compiler = stub 'compiler', :catalog => @catalog + @compiler = stub 'compiler', :catalog => @catalog, :environment => nil @scope = Puppet::Parser::Scope.new @scope.stubs(:findresource) diff --git a/spec/unit/parser/functions/tag_spec.rb b/spec/unit/parser/functions/tag_spec.rb index ff37badbb..dac134134 100755 --- a/spec/unit/parser/functions/tag_spec.rb +++ b/spec/unit/parser/functions/tag_spec.rb @@ -6,6 +6,7 @@ describe "the 'tag' function" do before :each do @scope = Puppet::Parser::Scope.new + @scope.stubs(:environment).returns(nil) end it "should exist" do |