summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-15 00:14:42 +0000
committershadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-15 00:14:42 +0000
commit3d070f71b55aefd2191b0027ecb2d2384e305085 (patch)
tree09e2ee76c7197382c530cc54d95a53a68f20da52
parent0cd579997a8ea619968c58a39493d28b9af87e6d (diff)
downloadpuppet-3d070f71b55aefd2191b0027ecb2d2384e305085.tar.gz
puppet-3d070f71b55aefd2191b0027ecb2d2384e305085.tar.xz
puppet-3d070f71b55aefd2191b0027ecb2d2384e305085.zip
These are the same versions from changeset 1837
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1932 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xtest/rails/railsparameter.rb31
-rwxr-xr-xtest/rails/railsresource.rb28
2 files changed, 33 insertions, 26 deletions
diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb
index 46a12e57c..f76939ac9 100755
--- a/test/rails/railsparameter.rb
+++ b/test/rails/railsparameter.rb
@@ -16,32 +16,33 @@ class TestRailsParameter < Test::Unit::TestCase
def test_to_resourceparam
railsinit
# First create our parameter
- rparam = nil
- hash = { :name => :myparam, :value => "myval",
- :file => __FILE__, :line => __LINE__}
+ #FIXME Need to re-add file/line support
+ pname = { :name => "myname" }
+ pvalue = { :value => "myval" }
+ pn = Puppet::Rails::ParamName.new(:name => pname[:name])
+ pv = Puppet::Rails::ParamValue.new(:value => pvalue[:value])
assert_nothing_raised do
- rparam = Puppet::Rails::RailsParameter.new(hash)
+ pn.param_values << pv
end
- assert(rparam, "Did not create rails parameter")
+ assert(pn, "Did not create rails parameter")
# The id doesn't get assigned until we save
- rparam.save
+ pn.save
# Now create a source
interp = mkinterp
source = interp.newclass "myclass"
# And try to convert our parameter
- pparam = nil
- assert_nothing_raised do
- pparam = rparam.to_resourceparam(source)
- end
-
-
- assert_instance_of(Puppet::Parser::Resource::Param, pparam)
- hash.each do |name, value|
- assert_equal(value, pparam.send(name), "%s was not equal" % name)
+ #FIXME Why does this assert prevent the block from executing?
+ #assert_nothing_raised do
+ pp = pn.to_resourceparam(source)
+ #end
+
+ assert_instance_of(Puppet::Parser::Resource::Param, pp)
+ pname.each do |name, value|
+ assert_equal(value.to_sym, pp.send(name), "%s was not equal" % name)
end
end
end
diff --git a/test/rails/railsresource.rb b/test/rails/railsresource.rb
index 666d26bcf..f16f925a8 100755
--- a/test/rails/railsresource.rb
+++ b/test/rails/railsresource.rb
@@ -22,33 +22,38 @@ class TestRailsResource < Test::Unit::TestCase
host = Puppet::Rails::Host.new(:name => "myhost")
# Now build a resource
- resource = host.rails_resources.build(
- :title => "/tmp/to_resource", :restype => "file",
- :exported => true
- )
-
+ resource = host.resources.create(
+ :title => "/tmp/to_resource",
+ :exported => true)
+
+ # For some reason the child class doesn't exist until after the resource is created.
+ # Probably an issue with the dynamic class generation.
+ resource.type = "PuppetFile"
+ resource.save
+
# Now add some params
{"owner" => "root", "mode" => "644"}.each do |param, value|
- resource.rails_parameters.build(
- :name => param, :value => value
- )
+ pn = resource.param_names.find_or_create_by_name(param)
+ pv = pn.param_values.find_or_create_by_value(value)
+ resource.param_names << pn
end
# Now save the whole thing
host.save
- # Now, try to convert our resource to a real resource
# We need a scope
interp, scope, source = mkclassframing
+ # Find the new resource and include all it's parameters.
+ resource = Puppet::Rails::Resource.find_by_id(resource.id, :include => [ :param_names, :param_values ])
+
+ # Now, try to convert our resource to a real resource
res = nil
assert_nothing_raised do
res = resource.to_resource(scope)
end
-
assert_instance_of(Puppet::Parser::Resource, res)
-
assert_equal("root", res[:owner])
assert_equal("644", res[:mode])
assert_equal("/tmp/to_resource", res.title)
@@ -60,3 +65,4 @@ else
end
# $Id$
+