diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-02 19:26:31 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-02 19:26:31 +0000 |
| commit | 75ec0543d27f3c552a778adae3255a3cb68f918b (patch) | |
| tree | d86c7845c7012820d1b89ae50283598fc46607d2 /test | |
| parent | 0d01770499d94c0d0140449569efe9126d97ea86 (diff) | |
| download | puppet-75ec0543d27f3c552a778adae3255a3cb68f918b.tar.gz puppet-75ec0543d27f3c552a778adae3255a3cb68f918b.tar.xz puppet-75ec0543d27f3c552a778adae3255a3cb68f918b.zip | |
committing initial tidy stuff, so i can move to the laptop
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@622 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/types/tc_tidy.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/test/types/tc_tidy.rb b/test/types/tc_tidy.rb new file mode 100755 index 000000000..0e6bcd562 --- /dev/null +++ b/test/types/tc_tidy.rb @@ -0,0 +1,78 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $puppetbase = "../../../../language/trunk" +end + +require 'puppet' +require 'puppettest' +require 'test/unit' + +# $Id$ + +class TestTidy < TestPuppet + include FileTesting + # hmmm + # this is complicated, because we store references to the created + # objects in a central store + def setup + Puppet[:loglevel] = :debug if __FILE__ == $0 + super + end + + def mktmpfile + # because luke's home directory is on nfs, it can't be used for testing + # as root + tmpfile = tempfile() + File.open(tmpfile, "w") { |f| f.puts rand(100) } + @@tmpfiles.push tmpfile + return tmpfile + end + + def mktmpdir + dir = File.join(tmpdir(), "puppetlinkdir") + unless FileTest.exists?(dir) + Dir.mkdir(dir) + end + @@tmpfiles.push dir + return dir + end + + def test_simpletidy + dir = mktmpdir + file = File.join(dir, "tidytesting") + File.open(file, "w") { |f| + f.puts rand(100) + } + + Puppet::Type::Tidy.new( + :name => file + ) + end + + def test_recursion + source = mktmpdir() + FileUtils.cd(source) { + mkranddirsandfiles() + } + + link = nil + assert_nothing_raised { + link = newlink(:target => source, :recurse => true) + } + comp = newcomp("linktest",link) + cycle(comp) + + path = link.name + list = file_list(path) + FileUtils.cd(path) { + list.each { |file| + unless FileTest.directory?(file) + assert(FileTest.symlink?(file)) + target = File.readlink(file) + assert_equal(target,File.join(source,file.sub(/^\.\//,''))) + end + } + } + end +end |
