summaryrefslogtreecommitdiffstats
path: root/test/language
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-12-09 17:02:29 -0600
committerLuke Kanies <luke@madstop.com>2008-12-18 11:10:21 -0600
commite3b1590f57a18b89c5f97ca0aa8e8d2bd9187b58 (patch)
tree12a504efed000f16bbe1d45e9e6f71471714ae44 /test/language
parentc306a1744793420337421f6fdf3630a9121861bd (diff)
downloadpuppet-e3b1590f57a18b89c5f97ca0aa8e8d2bd9187b58.tar.gz
puppet-e3b1590f57a18b89c5f97ca0aa8e8d2bd9187b58.tar.xz
puppet-e3b1590f57a18b89c5f97ca0aa8e8d2bd9187b58.zip
Adding resource convertion to the parser resources
Also uses Puppet::Resource's method for creating transportable resources. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'test/language')
-rwxr-xr-xtest/language/resource.rb84
1 files changed, 0 insertions, 84 deletions
diff --git a/test/language/resource.rb b/test/language/resource.rb
index b3eaf0390..fa04117f1 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -84,53 +84,6 @@ class TestResource < PuppetTest::TestCase
res.send(:paramcheck, :other)
end
- def test_to_transobject
- # First try translating a builtin resource. Make sure we use some references
- # and arrays, to make sure they translate correctly.
- source = mock("source")
- scope = mkscope
- scope.stubs(:tags).returns([])
- refs = []
- 4.times { |i| refs << Puppet::Parser::Resource::Reference.new(:title => "file%s" % i, :type => "file") }
- res = Parser::Resource.new :type => "file", :title => "/tmp",
- :source => source, :scope => scope,
- :params => paramify(source, :owner => "nobody", :group => %w{you me},
- :require => refs[0], :ignore => %w{svn},
- :subscribe => [refs[1], refs[2]], :notify => [refs[3]])
-
- obj = nil
- assert_nothing_raised do
- obj = res.to_trans
- end
-
- assert_instance_of(Puppet::TransObject, obj)
-
- assert_equal(obj.type, res.type.downcase)
- assert_equal(obj.name, res.title)
-
- # TransObjects use strings, resources use symbols
- assert_equal("nobody", obj["owner"], "Single-value string was not passed correctly")
- assert_equal(%w{you me}, obj["group"], "Array of strings was not passed correctly")
- assert_equal("svn", obj["ignore"], "Array with single string was not turned into single value")
- assert_equal(["file", refs[0].title], obj["require"], "Resource reference was not passed correctly")
- assert_equal([["file", refs[1].title], ["file", refs[2].title]], obj["subscribe"], "Array of resource references was not passed correctly")
- assert_equal(["file", refs[3].title], obj["notify"], "Array with single resource reference was not turned into single value")
- end
-
- # FIXME This isn't a great test, but I need to move on.
- def test_to_transbucket
- bucket = mock("transbucket")
- source = mock("source")
- scope = mkscope
- res = Parser::Resource.new :type => "mydefine", :title => "yay",
- :source => source, :scope => scope
-
-
- result = res.to_trans
- assert_equal("yay", result.name, "did not set bucket name correctly")
- assert_equal("Mydefine", result.type, "did not set bucket type correctly")
- end
-
def test_evaluate
# First try the most common case, we're not a builtin type.
res = mkresource
@@ -154,43 +107,6 @@ class TestResource < PuppetTest::TestCase
assert_equal(false, res.builtin?)
end
- def test_reference_conversion
- # First try it as a normal string
- ref = Parser::Resource::Reference.new(:type => "file", :title => "/tmp/ref1")
-
- # Now create an obj that uses it
- res = mkresource :type => "file", :title => "/tmp/resource",
- :params => {:require => ref}
- res.scope = mkscope
-
- trans = nil
- assert_nothing_raised do
- trans = res.to_trans
- end
-
- assert_instance_of(Array, trans["require"])
- assert_equal(["file", "/tmp/ref1"], trans["require"])
-
- # Now try it when using an array of references.
- two = Parser::Resource::Reference.new(:type => "file", :title => "/tmp/ref2")
- res = mkresource :type => "file", :title => "/tmp/resource2",
- :params => {:require => [ref, two]}
- res.scope = mkscope
-
- trans = nil
- assert_nothing_raised do
- trans = res.to_trans
- end
-
- assert_instance_of(Array, trans["require"][0])
- trans["require"].each do |val|
- assert_instance_of(Array, val)
- assert_equal("file", val[0])
- assert(val[1] =~ /\/tmp\/ref[0-9]/,
- "Was %s instead of the file name" % val[1])
- end
- end
-
# This is a bit of a weird one -- the user should not actually know
# that components exist, so we want references to act like they're not
# builtin