summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/types/file.rb15
-rwxr-xr-xtest/types/type.rb36
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$