diff options
| author | shafer <shafer@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-13 20:59:57 +0000 |
|---|---|---|
| committer | shafer <shafer@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-13 20:59:57 +0000 |
| commit | 79961e1fb057abb76d92e8554465b7bf2a215762 (patch) | |
| tree | edc09d9fd7dd5ac927352d2de95af6015f12acc7 | |
| parent | 157953a125f3ed74db58bd5ed66d7e99f7937074 (diff) | |
| download | puppet-79961e1fb057abb76d92e8554465b7bf2a215762.tar.gz puppet-79961e1fb057abb76d92e8554465b7bf2a215762.tar.xz puppet-79961e1fb057abb76d92e8554465b7bf2a215762.zip | |
added test case for ignore
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@655 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | test/types/tc_fileignoresource.rb | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/test/types/tc_fileignoresource.rb b/test/types/tc_fileignoresource.rb new file mode 100644 index 000000000..ab225ee18 --- /dev/null +++ b/test/types/tc_fileignoresource.rb @@ -0,0 +1,140 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $:.unshift "../../../../language/trunk/lib" + $puppetbase = "../../../../language/trunk" +end + +require 'puppet' +require 'cgi' +require 'test/unit' +require 'fileutils' +require 'puppettest' + +# $Id: $ + +class TestFileIgnoreSources < Test::Unit::TestCase + include FileTesting + + def setup + @@tmpfiles = [] + @@tmppids = [] + Puppet[:loglevel] = :debug if __FILE__ == $0 + Puppet[:checksumfile] = File.join(Puppet[:statedir], "checksumtestfile") + begin + initstorage + rescue + system("rm -rf %s" % Puppet[:checksumfile]) + end + end + + def teardown + clearstorage + Puppet::Type.allclear + @@tmppids.each { |pid| + system("kill -INT %s" % pid) + } + @@tmpfiles.each { |file| + if FileTest.exists?(file) + system("chmod -R 755 %s" % file) + system("rm -rf %s" % file) + end + } + @@tmpfiles.clear + system("rm -f %s" % Puppet[:checksumfile]) + end + +#This is not needed unless using md5 (correct me if I'm wrong) + def initstorage + Puppet::Storage.init + Puppet::Storage.load + end + + def clearstorage + Puppet::Storage.store + Puppet::Storage.clear + end + + def test_ignore_simple_source + + #Temp directory to run tests in + path = "/tmp/Fileignoresourcetest" + @@tmpfiles.push path + + #source directory + sourcedir = "sourcedir" + sourcefile1 = "sourcefile1" + sourcefile2 = "sourcefile2" + + frompath = File.join(path,sourcedir) + FileUtils.mkdir_p frompath + + topath = File.join(path,"destdir") + FileUtils.mkdir topath + + #initialize variables before block + tofile = nil + trans = nil + + #create source files + + File.open(File.join(frompath,sourcefile1), File::WRONLY|File::CREAT|File::APPEND) { |of| + of.puts "yayness" + } + + File.open(File.join(frompath,sourcefile2), File::WRONLY|File::CREAT|File::APPEND) { |of| + of.puts "even yayer" + } + + + #makes Puppet file Object + assert_nothing_raised { + tofile = Puppet::Type::PFile.new( + :name => topath, + :source => frompath, + :recurse => true, + :ignore => "sourcefile2" + ) + } + + #make a component and adds the file + comp = Puppet::Type::Component.new( + :name => "component" + ) + comp.push tofile + + #make, evaluate transaction and sync the component + assert_nothing_raised { + trans = comp.evaluate + } + assert_nothing_raised { + trans.evaluate + } + assert_nothing_raised { + comp.sync + } + + #topath should exist as a directory with sourcedir as a directory + newpath = File.join(topath, sourcedir) + assert(FileTest.exists?(newpath)) + + #This file should exist + assert(FileTest.exists?(File.join(newpath,sourcefile1))) + + #This file should not + assert(!(FileTest.exists?(File.join(newpath,sourcefile2)))) + + puts "we made it" + + Puppet::Type.allclear + + end + + def test_ignore_with_wildcard + end + + def test_ignore_complex + end + + +end |
