summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-12 01:58:19 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-12 01:58:19 +0000
commit411ab22588da2cbe76d186fbd4b59f6194766c4d (patch)
tree149909b773377b9a11bf5f68e7d104b1f975047c /test
parent97fb6c91d60cfe20f0521a7148d202ed25434b7d (diff)
Adding autorequire to files, and added the cwd to the list of files to be required for exec. Also, exec catches inline files and autorequires them.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@805 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/puppettest.rb2
-rwxr-xr-xtest/server/fileserver.rb2
-rwxr-xr-xtest/types/exec.rb24
-rw-r--r--test/types/file.rb20
-rwxr-xr-xtest/types/filebucket.rb5
-rw-r--r--test/types/fileignoresource.rb5
-rwxr-xr-xtest/types/filesources.rb5
7 files changed, 45 insertions, 18 deletions
diff --git a/test/puppettest.rb b/test/puppettest.rb
index 202d57478..d489cd5e8 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -122,7 +122,7 @@ module TestPuppet
return f
end
- def testdir
+ def tstdir
if defined? @testdirnum
@testdirnum += 1
else
diff --git a/test/server/fileserver.rb b/test/server/fileserver.rb
index d1cdd696b..bc610f65b 100755
--- a/test/server/fileserver.rb
+++ b/test/server/fileserver.rb
@@ -631,7 +631,7 @@ class TestFileServer < Test::Unit::TestCase
def test_filereread
server = nil
- dir = testdir()
+ dir = tstdir()
files = mktestfiles(dir)
diff --git a/test/types/exec.rb b/test/types/exec.rb
index 02bb5e9eb..446865774 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -229,17 +229,39 @@ class TestExec < Test::Unit::TestCase
:mode => 755
)
+ basedir = File.dirname(oexe)
+ baseobj = Puppet.type(:file).create(
+ :name => basedir,
+ :source => exe,
+ :mode => 755
+ )
+
ofile = Puppet.type(:file).create(
:name => exe,
:mode => 755
)
exec = Puppet.type(:exec).create(
- :name => oexe
+ :name => oexe,
+ :cwd => basedir
)
+ cat = Puppet.type(:exec).create(
+ :name => "cat %s" % oexe,
+ :path => ENV["PATH"]
+ )
+
+ # Verify we get the script itself
assert(exec.requires?(file), "Exec did not autorequire file")
+
+ # Verify we catch the cwd
+ assert(exec.requires?(baseobj), "Exec did not autorequire cwd")
+
+ # Verify we don't require ourselves
assert(!exec.requires?(ofile), "Exec incorrectly required file")
+
+ # Verify that we catch inline files
+ assert(cat.requires?(file), "Exec did not catch inline file")
end
if Process.uid == 0
diff --git a/test/types/file.rb b/test/types/file.rb
index 1e70b725f..93332e06a 100644
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -566,6 +566,26 @@ class TestFile < Test::Unit::TestCase
assert_equal("file=%s" % file.name, file.path)
end
+
+ def test_autorequire
+ basedir = tempfile()
+ subfile = File.join(basedir, "subfile")
+
+ baseobj = Puppet.type(:file).create(
+ :name => basedir,
+ :create => "directory"
+ )
+
+ subobj = Puppet.type(:file).create(
+ :name => subfile,
+ :create => "file"
+ )
+
+ assert(subobj.requires?(baseobj), "File did not require basedir")
+ assert(!subobj.requires?(subobj), "File required itself")
+ comp = newcomp(subobj, baseobj)
+ assert_events([:directory_created, :file_created], comp)
+ end
end
# $Id$
diff --git a/test/types/filebucket.rb b/test/types/filebucket.rb
index 909170f77..5220eea98 100755
--- a/test/types/filebucket.rb
+++ b/test/types/filebucket.rb
@@ -56,11 +56,6 @@ class TestFileBucket < Test::Unit::TestCase
end
end
- def teardown
- super
- clearstorage
- end
-
def initstorage
Puppet::Storage.init
Puppet::Storage.load
diff --git a/test/types/fileignoresource.rb b/test/types/fileignoresource.rb
index 688b57845..ce8352384 100644
--- a/test/types/fileignoresource.rb
+++ b/test/types/fileignoresource.rb
@@ -24,11 +24,6 @@ class TestFileIgnoreSources < Test::Unit::TestCase
end
end
- def teardown
- super
- clearstorage
- end
-
#This is not needed unless using md5 (correct me if I'm wrong)
def initstorage
Puppet::Storage.init
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index 8dd0ca6b5..5ae728c81 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -27,11 +27,6 @@ class TestFileSources < Test::Unit::TestCase
end
end
- def teardown
- super
- clearstorage
- end
-
def initstorage
Puppet::Storage.init
Puppet::Storage.load