summaryrefslogtreecommitdiffstats
path: root/test/language
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-18 23:08:32 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-18 23:08:32 +0000
commit66546610ceb5f14d7dce1da9286def4b1497bd60 (patch)
tree4a6b7e768ec06d28c1ab92dbfd28a018b5f7593c /test/language
parent5ecfd39340f70b8c49e53e2c472e92aeafde3992 (diff)
downloadpuppet-66546610ceb5f14d7dce1da9286def4b1497bd60.tar.gz
puppet-66546610ceb5f14d7dce1da9286def4b1497bd60.tar.xz
puppet-66546610ceb5f14d7dce1da9286def4b1497bd60.zip
Fixing #538. There is now a simple file() function to read in file contents.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2298 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/language')
-rwxr-xr-xtest/language/functions.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/language/functions.rb b/test/language/functions.rb
index e3ab1ca1e..941f56c2c 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -445,6 +445,34 @@ class TestLangFunctions < Test::Unit::TestCase
"class %s was not evaluated" % c)
end
end
+
+ def test_file
+ interp = mkinterp
+ scope = mkscope(:interp => interp)
+
+ file1 = tempfile
+ file2 = tempfile
+ file3 = tempfile
+
+ File.open(file2, "w") { |f| f.puts "yaytest" }
+
+ val = nil
+ assert_nothing_raised("Failed to call file with one arg") do
+ val = scope.function_file([file2])
+ end
+
+ assert_equal("yaytest\n", val, "file() failed")
+
+ assert_nothing_raised("Failed to call file with two args") do
+ val = scope.function_file([file1, file2])
+ end
+
+ assert_equal("yaytest\n", val, "file() failed")
+
+ assert_raise(Puppet::ParseError, "did not fail when files are missing") do
+ val = scope.function_file([file1, file3])
+ end
+ end
end
# $Id$