diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-28 06:49:03 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-28 06:49:03 +0000 |
commit | a5cf0560c8f3d1119659c87473455eb141608e51 (patch) | |
tree | 2a230f853ad99b1874399d2e9d4229291b04e8a2 /test | |
parent | 883c64aaa0c0a81fa299424dec4a61f73c910820 (diff) | |
download | puppet-a5cf0560c8f3d1119659c87473455eb141608e51.tar.gz puppet-a5cf0560c8f3d1119659c87473455eb141608e51.tar.xz puppet-a5cf0560c8f3d1119659c87473455eb141608e51.zip |
Fixing #388. Paths now look a lot cleaner.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1977 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-x | test/types/file.rb | 15 | ||||
-rwxr-xr-x | test/types/type.rb | 36 |
2 files changed, 51 insertions, 0 deletions
diff --git a/test/types/file.rb b/test/types/file.rb index f4111baf1..0a330eee3 100755 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -1893,6 +1893,21 @@ class TestFile < Test::Unit::TestCase assert_equal(obj.bucket, file[:backup], "bucket was not retrieved") assert_equal(obj.bucket, file.bucket, "file's bucket was not set") end + + def test_pathbuilder + dir = tempfile() + Dir.mkdir(dir) + file = File.join(dir, "file") + File.open(file, "w") { |f| f.puts "" } + obj = Puppet::Type.newfile :path => dir, :recurse => true, :mode => 0755 + + assert_equal("/%s" % obj.ref, obj.path) + + list = obj.eval_generate + fileobj = obj.class[file] + assert(fileobj, "did not generate file object") + assert_equal("/%s" % fileobj.ref, fileobj.path, "did not generate correct subfile path") + end end # $Id$ diff --git a/test/types/type.rb b/test/types/type.rb index e8a4d45f1..8a90271d6 100755 --- a/test/types/type.rb +++ b/test/types/type.rb @@ -775,6 +775,42 @@ end file[:noop] = false assert(file.noop, "file should be in noop") end + + def test_path + # Check that our paths are built correctly. Just pick a random, "normal" type. + type = Puppet::Type.type(:exec) + mk = Proc.new do |i, hash| + hash[:title] = "exec%s" % i + hash[:command] = "/bin/echo" + type.create(hash) + end + + exec = mk.call(1, {}) + + assert_equal("/Exec[exec1]", exec.path) + + comp = Puppet::Type.newcomponent :title => "My[component]", :type => "Yay" + + exec = mk.call(2, :parent => comp) + + assert_equal("/My[component]/Exec[exec2]", exec.path) + + comp = Puppet::Type.newcomponent :name => "Other[thing]" + exec = mk.call(3, :parent => comp) + assert_equal("/Other[thing]/Exec[exec3]", exec.path) + + comp = Puppet::Type.newcomponent :type => "server", :name => "server" + exec = mk.call(4, :parent => comp) + assert_equal("/server/Exec[exec4]", exec.path) + + comp = Puppet::Type.newcomponent :type => "whatever", :name => "main[top]" + exec = mk.call(5, :parent => comp) + assert_equal("//Exec[exec5]", exec.path) + + comp = Puppet::Type.newcomponent :type => "yay", :name => "Good[bad]", :parent => comp + exec = mk.call(6, :parent => comp) + assert_equal("//Good[bad]/Exec[exec6]", exec.path) + end end # $Id$ |