1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
require 'spec_helper'
require 'puppet_spec/compiler'
require 'puppet_spec/files'
require 'puppet/file_bucket/dipper'
describe Puppet::Type.type(:tidy) do
include PuppetSpec::Files
include PuppetSpec::Compiler
before do
allow(Puppet::Util::Storage).to receive(:store)
end
it "should be able to recursively remove directories" do
dir = tmpfile("tidy_testing")
FileUtils.mkdir_p(File.join(dir, "foo", "bar"))
apply_compiled_manifest(<<-MANIFEST)
tidy { '#{dir}':
recurse => true,
rmdirs => true,
}
MANIFEST
expect(Puppet::FileSystem.directory?(dir)).to be_falsey
end
# Testing #355.
it "should be able to remove dead links", :if => Puppet.features.manages_symlinks? do
dir = tmpfile("tidy_link_testing")
link = File.join(dir, "link")
target = tmpfile("no_such_file_tidy_link_testing")
Dir.mkdir(dir)
Puppet::FileSystem.symlink(target, link)
apply_compiled_manifest(<<-MANIFEST)
tidy { '#{dir}':
recurse => true,
}
MANIFEST
expect(Puppet::FileSystem.symlink?(link)).to be_falsey
end
end
|