summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2010-04-12 11:17:52 -0700
committerLuke Kanies <luke@puppetlabs.com>2010-04-12 11:17:52 -0700
commit03532e087946fb4002b218eec477899ffb5860b3 (patch)
treee5b6379fff049fe3f4c341cbc8f7d3cfc4c60ff5
parent006e6afd6e15c32ef0b49eefd0366fba694a0cf5 (diff)
downloadpuppet-03532e087946fb4002b218eec477899ffb5860b3.tar.gz
puppet-03532e087946fb4002b218eec477899ffb5860b3.tar.xz
puppet-03532e087946fb4002b218eec477899ffb5860b3.zip
Porting a simple set of tests from test/unit
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
-rwxr-xr-xspec/unit/type/file.rb19
-rwxr-xr-xtest/ral/type/file.rb63
2 files changed, 19 insertions, 63 deletions
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 64ac135f8..f9c691b11 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -16,6 +16,25 @@ describe Puppet::Type.type(:file) do
@file.catalog = @catalog
end
+ describe "when determining if recursion is enabled" do
+ it "should default to recursion being disabled" do
+ @file.should_not be_recurse
+ end
+ [true, "true", 10, "inf", "remote"].each do |value|
+ it "should consider #{value} to enable recursion" do
+ @file[:recurse] = value
+ @file.must be_recurse
+ end
+ end
+
+ [false, "false", 0].each do |value|
+ it "should consider #{value} to disable recursion" do
+ @file[:recurse] = value
+ @file.should_not be_recurse
+ end
+ end
+ end
+
describe "#write" do
it "should propagate failures encountered when renaming the temporary file" do
diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb
index daa215adf..710376643 100755
--- a/test/ral/type/file.rb
+++ b/test/ral/type/file.rb
@@ -378,69 +378,6 @@ class TestFile < Test::Unit::TestCase
}
end
- def test_recurse?
- file = Puppet::Type.type(:file).new :path => tempfile
-
- # Make sure we default to false
- assert(! file.recurse?, "Recurse defaulted to true")
-
- [true, "true", 10, "inf", "remote"].each do |value|
- file[:recurse] = value
- assert(file.recurse?, "%s did not cause recursion" % value)
- end
-
- [false, "false", 0].each do |value|
- file[:recurse] = value
- assert(! file.recurse?, "%s caused recursion" % value)
- end
- end
-
- def test_recursion
- basedir = tempfile()
- subdir = File.join(basedir, "subdir")
- tmpfile = File.join(basedir,"testing")
- FileUtils.mkdir_p(subdir)
-
- dir = nil
- [true, "true", "inf", 50].each do |value|
- assert_nothing_raised {
- dir = Puppet::Type.type(:file).new(
- :path => basedir,
- :recurse => value,
- :check => %w{owner mode group}
- )
- }
- config = mk_catalog dir
- transaction = Puppet::Transaction.new(config)
-
- children = nil
-
- assert_nothing_raised {
- children = transaction.eval_generate(dir)
- }
-
- assert_equal([subdir], children.collect {|c| c.title },
- "Incorrect generated children")
-
- # Remove our subdir resource,
- subdir_resource = config.resource(:file, subdir)
- config.remove_resource(subdir_resource)
-
- # Create the test file
- File.open(tmpfile, "w") { |f| f.puts "yayness" }
-
- assert_nothing_raised {
- children = transaction.eval_generate(dir)
- }
-
- # And make sure we get both resources back.
- assert_equal([subdir, tmpfile].sort, children.collect {|c| c.title }.sort,
- "Incorrect generated children when recurse == %s" % value.inspect)
-
- File.unlink(tmpfile)
- end
- end
-
def test_filetype_retrieval
file = nil