summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-02 01:55:09 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-02 01:55:09 +0000
commited42371ca97af285ab326691c5d33f55c727f981 (patch)
tree766d6045764be6c74eb1025e858138570f50a858 /test
parent6af0e0e5959e7b405191e0a916be097454a656e4 (diff)
Switched @should to an array, so all objects can now handle that. I have not yet gone through and done the other cool things that can result, but that will have to wait until tomorrow. Also, I moved all of the pfile states into separate files, since the file was getting unweildy.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@712 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/certmgr/tc_certmgr.rb2
-rw-r--r--test/puppettest.rb14
-rw-r--r--test/server/tc_bucket.rb1
-rw-r--r--test/server/tc_master.rb1
-rw-r--r--test/types/tc_basic.rb15
-rw-r--r--test/types/tc_file.rb7
-rwxr-xr-xtest/types/tc_filebucket.rb1
-rwxr-xr-xtest/types/tc_filesources.rb34
8 files changed, 33 insertions, 42 deletions
diff --git a/test/certmgr/tc_certmgr.rb b/test/certmgr/tc_certmgr.rb
index b67ff920d..ec1cb62c4 100755
--- a/test/certmgr/tc_certmgr.rb
+++ b/test/certmgr/tc_certmgr.rb
@@ -221,7 +221,7 @@ class TestCertMgr < Test::Unit::TestCase
def test_interactiveca
ca = nil
Puppet[:ssldir] = "/tmp/puppetinteractivecatest"
- @@tmpfiles.push Puppet[:ssldir]
+ @@tmpfiles << Puppet[:ssldir]
assert_nothing_raised {
ca = Puppet::SSLCertificates::CA.new
diff --git a/test/puppettest.rb b/test/puppettest.rb
index f18675549..6b91f1049 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -1,4 +1,3 @@
-# $Id$
require 'test/unit'
libdir = File.join(File.dirname(__FILE__), '../lib')
@@ -360,7 +359,12 @@ class FileTesting < TestPuppet
}
tolist = file_list(todir).sort
- assert_equal(fromlist,tolist)
+ fromlist.sort.zip(tolist.sort).each { |a,b|
+ assert_equal(a, b,
+ "Fromfile %s with length %s does not match tofile %s with length %s" %
+ [a, fromlist.length, b, tolist.length])
+ }
+ #assert_equal(fromlist,tolist)
# and then do some verification that the files are actually set up
# the same
@@ -404,12 +408,14 @@ class FileTesting < TestPuppet
end
def delete_random_files(dir)
+ deleted = []
random_files(dir) { |file|
stat = File.stat(file)
begin
if stat.ftype == "directory"
false
else
+ deleted << file
File.unlink(file)
true
end
@@ -419,6 +425,8 @@ class FileTesting < TestPuppet
false
end
}
+
+ return deleted
end
def add_random_files(dir)
@@ -549,3 +557,5 @@ def failers
yield file
}
end
+
+# $Id$
diff --git a/test/server/tc_bucket.rb b/test/server/tc_bucket.rb
index 8a7e71511..49f01287a 100644
--- a/test/server/tc_bucket.rb
+++ b/test/server/tc_bucket.rb
@@ -196,6 +196,7 @@ class TestBucket < ServerTest
files = filelist()
tmpdir = File.join(tmpdir(),"tmpfiledir")
+ @@tmpfiles << tmpdir
FileUtils.mkdir_p(tmpdir)
Puppet[:autosign] = true
diff --git a/test/server/tc_master.rb b/test/server/tc_master.rb
index 4fb8df8b2..f4d5d967b 100644
--- a/test/server/tc_master.rb
+++ b/test/server/tc_master.rb
@@ -105,6 +105,7 @@ class TestMaster < ServerTest
manifest = mktestmanifest()
file2 = @createdfile + "2"
+ @@tmpfiles << file2
client = master = nil
assert_nothing_raised() {
diff --git a/test/types/tc_basic.rb b/test/types/tc_basic.rb
index f0257fef0..6ba91f076 100644
--- a/test/types/tc_basic.rb
+++ b/test/types/tc_basic.rb
@@ -5,15 +5,15 @@ if __FILE__ == $0
end
require 'puppet'
+require 'puppettest'
require 'test/unit'
-# $Id$
-
-class TestBasic < Test::Unit::TestCase
+class TestBasic < TestPuppet
# hmmm
# this is complicated, because we store references to the created
# objects in a central store
def setup
+ super
@component = nil
@configfile = nil
@sleeper = nil
@@ -29,7 +29,7 @@ class TestBasic < Test::Unit::TestCase
assert_nothing_raised() {
@filepath = "/tmp/testfile"
- system("rm -f %s" % @filepath)
+ @@tmpfiles << @filepath
@configfile = Puppet::Type::PFile.create(
:path => @filepath,
:create => true,
@@ -55,11 +55,6 @@ class TestBasic < Test::Unit::TestCase
#puts "ConfigFile is %s, id %s" % [@configfile, @configfile.object_id]
end
- def teardown
- Puppet::Type.allclear
- system("rm -f %s" % @filepath)
- end
-
def test_name_calls
[@sleeper,@configfile].each { |obj|
Puppet.debug "obj is %s" % obj
@@ -118,3 +113,5 @@ class TestBasic < Test::Unit::TestCase
}
end
end
+
+# $Id$
diff --git a/test/types/tc_file.rb b/test/types/tc_file.rb
index 8b19dc670..ec357dcc0 100644
--- a/test/types/tc_file.rb
+++ b/test/types/tc_file.rb
@@ -1,8 +1,7 @@
if __FILE__ == $0
$:.unshift '..'
$:.unshift '../../lib'
- $:.unshift "../../../../language/trunk/lib"
- $puppetbase = "../../../../language/trunk"
+ $puppetbase = "../.."
end
require 'puppet'
@@ -10,8 +9,6 @@ require 'test/unit'
require 'fileutils'
require 'puppettest'
-# $Id$
-
class TestFile < FileTesting
# hmmm
# this is complicated, because we store references to the created
@@ -500,3 +497,5 @@ class TestFile < FileTesting
}
end
end
+
+# $Id$
diff --git a/test/types/tc_filebucket.rb b/test/types/tc_filebucket.rb
index 6c57c8dab..a8ba7a8c3 100755
--- a/test/types/tc_filebucket.rb
+++ b/test/types/tc_filebucket.rb
@@ -125,6 +125,7 @@ class TestFileBucket < FileTesting
}
opath = "/tmp/anotherbuckettest"
+ @@tmpfiles << opath
system("cp /etc/passwd %s" % opath)
origmd5 = File.open(file.name) { |f| newmd5 = Digest::MD5.hexdigest(f.read) }
diff --git a/test/types/tc_filesources.rb b/test/types/tc_filesources.rb
index 0de4157bc..031e1b76e 100755
--- a/test/types/tc_filesources.rb
+++ b/test/types/tc_filesources.rb
@@ -11,28 +11,7 @@ require 'test/unit'
require 'fileutils'
require 'puppettest'
-# $Id$
-
class TestFileSources < FileTesting
-
-=begin
- def mkfile(hash)
- file = nil
- assert_nothing_raised {
- file = Puppet::Type::PFile.create(hash)
- }
- return file
- end
-
- def mktestfile
- # 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
- mkfile(:name => tmpfile)
- end
-=end
def setup
begin
initstorage
@@ -83,10 +62,6 @@ class TestFileSources < FileTesting
child = file.newchild("childtest")
}
assert(child)
- assert_nothing_raised {
- child = file.newchild("childtest")
- }
- assert(child)
assert_raise(Puppet::DevError) {
file.newchild(File.join(path,"childtest"))
}
@@ -133,6 +108,7 @@ class TestFileSources < FileTesting
end
def recursive_source_test(fromdir, todir)
+ Puppet::Type.allclear
initstorage
tofile = nil
trans = nil
@@ -196,11 +172,15 @@ class TestFileSources < FileTesting
fromdir, todir = run_complex_sources
# then delete some files
assert(FileTest.exists?(todir))
- delete_random_files(todir)
+ missing_files = delete_random_files(todir)
# and run
recursive_source_test(fromdir, todir)
+ missing_files.each { |file|
+ assert(FileTest.exists?(file), "Deleted file %s is still missing" % file)
+ }
+
# and make sure they're still equal
assert_trees_equal(fromdir,todir)
end
@@ -547,3 +527,5 @@ class TestFileSources < FileTesting
assert(!FileTest.exists?(name), "File with no source exists anyway")
end
end
+
+# $Id$