summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/functions
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-10-21 14:23:32 -0700
committerNick Lewis <nick@puppetlabs.com>2011-04-12 12:47:31 -0700
commitd5dc3036eda210f318160e2442f7b65e0995ee23 (patch)
treec15071fb940f1c1d97a44068369d055a5e6c5d7a /spec/unit/parser/functions
parentb3baee8c625d1a8d8fb8be20d1534ed71188a5f2 (diff)
downloadpuppet-d5dc3036eda210f318160e2442f7b65e0995ee23.tar.gz
puppet-d5dc3036eda210f318160e2442f7b65e0995ee23.tar.xz
puppet-d5dc3036eda210f318160e2442f7b65e0995ee23.zip
Fix for #5063 -- explicitly scope internal variable lookups
When we lookup a global variable / fact from code we should explicitly look in the global scope.
Diffstat (limited to 'spec/unit/parser/functions')
-rwxr-xr-xspec/unit/parser/functions/extlookup_spec.rb10
-rwxr-xr-xspec/unit/parser/functions/fqdn_rand_spec.rb20
2 files changed, 15 insertions, 15 deletions
diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb
index f2560d3d9..ad89f6575 100755
--- a/spec/unit/parser/functions/extlookup_spec.rb
+++ b/spec/unit/parser/functions/extlookup_spec.rb
@@ -65,7 +65,7 @@ describe "the extlookup function" do
describe "should look in $extlookup_datadir for data files listed by $extlookup_precedence" do
before do
- @scope.stubs(:lookupvar).with('extlookup_datadir').returns("/tmp")
+ @scope.stubs(:lookupvar).with('::extlookup_datadir').returns("/tmp")
File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" }
File.open("/tmp/two.csv","w") do |two|
two.puts "key,value2"
@@ -74,21 +74,21 @@ 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"])
+ @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"])
+ @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')
+ @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
diff --git a/spec/unit/parser/functions/fqdn_rand_spec.rb b/spec/unit/parser/functions/fqdn_rand_spec.rb
index d810741c5..90792e182 100755
--- a/spec/unit/parser/functions/fqdn_rand_spec.rb
+++ b/spec/unit/parser/functions/fqdn_rand_spec.rb
@@ -16,49 +16,49 @@ describe "the fqdn_rand function" do
end
it "should handle 0 arguments" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([]) }.should_not raise_error(Puppet::ParseError)
end
it "should handle 1 argument'}" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3]) }.should_not raise_error(Puppet::ParseError)
end
(1..10).each { |n|
it "should handle #{n} additional arguments" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3,1,2,3,4,5,6,7,8,9,10][0..n]) }.should_not raise_error(Puppet::ParseError)
end
it "should handle #{n} additional string arguments" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3,%w{ 1 2 3 4 5 6 7 8 9 10}].flatten[0..n]) }.should_not raise_error(Puppet::ParseError)
end
}
it "should return a value less than max" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
@scope.function_fqdn_rand([3]).should satisfy {|n| n.to_i < 3 }
end
it "should return the same values on subsequent invocations for the same host" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1").twice
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
@scope.function_fqdn_rand([3,4]).should eql(@scope.function_fqdn_rand([3, 4]))
end
it "should return different sequences of value for different hosts" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val1 = @scope.function_fqdn_rand([10000000,4])
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.2")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.2")
val2 = @scope.function_fqdn_rand([10000000,4])
val1.should_not eql(val2)
end
it "should return different values for the same hosts with different seeds" do
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val1 = @scope.function_fqdn_rand([10000000,4])
- @scope.expects(:lookupvar).with("fqdn").returns("127.0.0.1")
+ @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val2 = @scope.function_fqdn_rand([10000000,42])
val1.should_not eql(val2)
end