summaryrefslogtreecommitdiff
path: root/test/types
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-08-17 05:08:36 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-08-17 05:08:36 +0000
commitbeba3e480c7ad7f942414a8aa31f96b5b42b53e4 (patch)
treed3c2949930af4462b5a1d03a46b0f8d76e087d0c /test/types
parent607d7c6afec7ab73203382676cc98b6d52898e1d (diff)
downloadpuppet-beba3e480c7ad7f942414a8aa31f96b5b42b53e4.tar.gz
Finishing changes to support titles instead of two types of names. This is basically a bug-fix commit.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1472 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/types')
-rwxr-xr-xtest/types/exec.rb31
-rw-r--r--test/types/file.rb17
-rwxr-xr-xtest/types/filesources.rb8
-rwxr-xr-xtest/types/symlink.rb2
-rw-r--r--test/types/type.rb32
5 files changed, 61 insertions, 29 deletions
diff --git a/test/types/exec.rb b/test/types/exec.rb
index f9f7592e3..4f66da517 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -200,13 +200,13 @@ class TestExec < Test::Unit::TestCase
File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" }
file = Puppet.type(:file).create(
- :name => oexe,
+ :path => oexe,
:source => exe,
:mode => 0755
)
exec = Puppet.type(:exec).create(
- :name => oexe,
+ :command => oexe,
:require => [:file, oexe]
)
@@ -223,31 +223,31 @@ class TestExec < Test::Unit::TestCase
File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" }
file = Puppet.type(:file).create(
- :name => oexe,
+ :path => oexe,
:source => exe,
:mode => 755
)
basedir = File.dirname(oexe)
baseobj = Puppet.type(:file).create(
- :name => basedir,
+ :path => basedir,
:source => exe,
:mode => 755
)
ofile = Puppet.type(:file).create(
- :name => exe,
+ :path => exe,
:mode => 755
)
exec = Puppet.type(:exec).create(
- :name => oexe,
+ :command => oexe,
:path => ENV["PATH"],
:cwd => basedir
)
cat = Puppet.type(:exec).create(
- :name => "cat %s %s" % [exe, oexe],
+ :command => "cat %s %s" % [exe, oexe],
:path => ENV["PATH"]
)
@@ -302,15 +302,16 @@ class TestExec < Test::Unit::TestCase
:path => ENV['PATH']
)
}
+ comp = newcomp(exec)
- assert_events([:executed_command], exec)
- assert_events([:executed_command], exec)
+ assert_events([:executed_command], comp)
+ assert_events([:executed_command], comp)
system("touch %s" % afile)
- assert_events([], exec)
- assert_events([], exec)
+ assert_events([], comp)
+ assert_events([], comp)
system("rm %s" % afile)
- assert_events([:executed_command], exec)
- assert_events([:executed_command], exec)
+ assert_events([:executed_command], comp)
+ assert_events([:executed_command], comp)
end
if Process.uid == 0
@@ -377,7 +378,7 @@ class TestExec < Test::Unit::TestCase
exec = nil
assert_nothing_raised {
exec = Puppet.type(:exec).create(
- :name => "logoutputesting",
+ :title => "logoutputesting",
:path => "/usr/bin:/bin",
:command => "echo logoutput is false",
:logoutput => false
@@ -408,7 +409,7 @@ class TestExec < Test::Unit::TestCase
path = File.join(basedir, "subfile")
assert_nothing_raised {
exec = Puppet.type(:exec).create(
- :name => "mkdir",
+ :title => "mkdir",
:path => "/usr/bin:/bin",
:creates => basedir,
:command => "mkdir %s; touch %s" % [basedir, path]
diff --git a/test/types/file.rb b/test/types/file.rb
index 34fba29fb..eeb976370 100644
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -151,7 +151,7 @@ class TestFile < Test::Unit::TestCase
obj = nil
assert_nothing_raised {
obj = Puppet.type(:file).create(
- :name => link,
+ :title => link,
:owner => user.name
)
}
@@ -327,7 +327,7 @@ class TestFile < Test::Unit::TestCase
def test_modes
file = mktestfile
# Set it to something else initially
- File.chmod(0775, file.name)
+ File.chmod(0775, file.title)
[0644,0755,0777,0641].each { |mode|
assert_nothing_raised() {
file[:mode] = mode
@@ -380,7 +380,7 @@ class TestFile < Test::Unit::TestCase
file.retrieve
- if file.name !~ /nonexists/
+ if file.title !~ /nonexists/
sum = file.state(:checksum)
assert_equal(sum.is, sum.should)
assert(sum.insync?)
@@ -664,7 +664,7 @@ class TestFile < Test::Unit::TestCase
assert(file, "Could not retrieve file object")
- assert_equal("file=%s" % file.name, file.path)
+ assert_equal("file=%s" % file.title, file.path)
end
def test_autorequire
@@ -817,7 +817,7 @@ class TestFile < Test::Unit::TestCase
file = nil
assert_nothing_raised {
file = Puppet.type(:file).create(
- :name => "fileness",
+ :title => "fileness",
:path => path,
:content => "this is some content"
)
@@ -868,7 +868,7 @@ class TestFile < Test::Unit::TestCase
obj = nil
assert_nothing_raised {
obj = Puppet.type(:file).create(
- :name => link,
+ :path => link,
:mode => "755"
)
}
@@ -1122,7 +1122,7 @@ class TestFile < Test::Unit::TestCase
bpath = tempfile()
Dir.mkdir(bpath)
Puppet::Type.type(:filebucket).create(
- :name => bucket, :path => bpath
+ :title => bucket, :path => bpath
)
obj[:backup] = bucket
@@ -1144,7 +1144,7 @@ class TestFile < Test::Unit::TestCase
}
obj = Puppet::Type.type(:file).create(
- :name => dest, :source => source
+ :title => dest, :source => source
)
assert_events([:file_created], obj)
@@ -1304,6 +1304,7 @@ class TestFile < Test::Unit::TestCase
:path => dest,
:source => source
)
+ assert(obj, "Did not create file")
assert_apply(obj)
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index b69e83008..8c1d40b6f 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -100,10 +100,10 @@ class TestFileSources < Test::Unit::TestCase
assert_nothing_raised {
tofile = Puppet.type(:file).create(
- :name => todir,
- "recurse" => true,
- "backup" => false,
- "source" => fromdir
+ :path => todir,
+ :recurse => true,
+ :backup => false,
+ :source => fromdir
)
}
assert_apply(tofile)
diff --git a/test/types/symlink.rb b/test/types/symlink.rb
index c44668448..408817cb7 100755
--- a/test/types/symlink.rb
+++ b/test/types/symlink.rb
@@ -41,7 +41,7 @@ class TestSymlink < Test::Unit::TestCase
unless hash.include?(:ensure)
hash[:ensure] = mktmpfile()
end
-
+
link = Puppet.type(:symlink).create(hash)
return link
end
diff --git a/test/types/type.rb b/test/types/type.rb
index 0ca607695..b87ca2bd5 100644
--- a/test/types/type.rb
+++ b/test/types/type.rb
@@ -207,7 +207,7 @@ class TestType < Test::Unit::TestCase
}
assert_equal(path, file[:path])
- assert_equal([name], file[:alias])
+ assert_equal(name, file.title)
assert_nothing_raised {
file.retrieve
@@ -655,6 +655,36 @@ end
assert_nil(obj.should(:type),
"Type param passed through")
end
+
+ def test_multiplenames
+ obj = nil
+ path = tempfile()
+ assert_raise ArgumentError do
+ obj = Puppet::Type.type(:file).create(
+ :name => path,
+ :path => path
+ )
+ end
+ end
+
+ def test_title_and_name
+ obj = nil
+ path = tempfile()
+ fileobj = Puppet::Type.type(:file)
+
+ assert_nothing_raised do
+ obj = fileobj.create(
+ :title => "myfile",
+ :path => path
+ )
+ end
+
+ assert_equal(obj, fileobj["myfile"],
+ "Could not retrieve obj by title")
+
+ assert_equal(obj, fileobj[path],
+ "Could not retrieve obj by name")
+ end
end
# $Id$