summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-13 07:49:48 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-13 07:49:48 +0000
commit35de0e3bd74e94de92ac0e9209a4884cf07c88a0 (patch)
treebe7119181bc15dad6575cc5b7087c92cfd7fbac8 /test
parent26b32b953d8e097785b38aa90e5e4bff6ae9247e (diff)
downloadpuppet-35de0e3bd74e94de92ac0e9209a4884cf07c88a0.tar.gz
puppet-35de0e3bd74e94de92ac0e9209a4884cf07c88a0.tar.xz
puppet-35de0e3bd74e94de92ac0e9209a4884cf07c88a0.zip
Temporarily reverting all of the recent rails work so that I can release 0.20.1
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1873 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/lib/puppettest/railstesting.rb10
-rwxr-xr-xtest/rails/rails.rb11
-rwxr-xr-xtest/rails/railsparameter.rb31
-rwxr-xr-xtest/rails/railsresource.rb27
4 files changed, 38 insertions, 41 deletions
diff --git a/test/lib/puppettest/railstesting.rb b/test/lib/puppettest/railstesting.rb
index e3b472b4f..3a32d0c9e 100644
--- a/test/lib/puppettest/railstesting.rb
+++ b/test/lib/puppettest/railstesting.rb
@@ -14,14 +14,16 @@ module PuppetTest::RailsTesting
host = Puppet::Rails::Host.new(:name => Facter.value("hostname"))
# Now build a resource
- resource = host.resources.build(
- :title => title, :exported => true
+ resource = host.rails_resources.build(
+ :title => title, :restype => type,
+ :exported => true
)
# Now add some params
params.each do |param, value|
- pvalue = ParamValue.new(:value => value)
- resource.param_name.find_or_create_by_name(param).param_values << pvalue
+ resource.rails_parameters.build(
+ :name => param, :value => value
+ )
end
# Now save the whole thing
diff --git a/test/rails/rails.rb b/test/rails/rails.rb
index 699d132a2..8be1bc66d 100755
--- a/test/rails/rails.rb
+++ b/test/rails/rails.rb
@@ -60,14 +60,13 @@ class TestRails < Test::Unit::TestCase
}
assert(host, "Could not find host object")
- assert(host.resources, "No objects on host")
+ assert(host.rails_resources, "No objects on host")
- # This changed from a hash to a method call, hope that doesn't break anything!
- assert_equal(facts["hostname"], host.facts("hostname"),
+ assert_equal(facts["hostname"], host.facts["hostname"],
"Did not retrieve facts")
count = 0
- host.resources.each do |resource|
+ host.rails_resources.each do |resource|
count += 1
i = nil
if resource[:title] =~ /file([0-9]+)/
@@ -75,7 +74,9 @@ class TestRails < Test::Unit::TestCase
else
raise "Got weird resource %s" % resource.inspect
end
- assert_equal("user#{i}", resource.parameters[:owner])
+
+ assert_equal("user#{i}",
+ resource.rails_parameters.find_by_name("owner")[:value])
end
assert_equal(20, count, "Did not get enough resources")
diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb
index f76939ac9..46a12e57c 100755
--- a/test/rails/railsparameter.rb
+++ b/test/rails/railsparameter.rb
@@ -16,33 +16,32 @@ class TestRailsParameter < Test::Unit::TestCase
def test_to_resourceparam
railsinit
# First create our parameter
- #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])
+ rparam = nil
+ hash = { :name => :myparam, :value => "myval",
+ :file => __FILE__, :line => __LINE__}
assert_nothing_raised do
- pn.param_values << pv
+ rparam = Puppet::Rails::RailsParameter.new(hash)
end
- assert(pn, "Did not create rails parameter")
+ assert(rparam, "Did not create rails parameter")
# The id doesn't get assigned until we save
- pn.save
+ rparam.save
# Now create a source
interp = mkinterp
source = interp.newclass "myclass"
# And try to convert our parameter
- #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)
+ 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)
end
end
end
diff --git a/test/rails/railsresource.rb b/test/rails/railsresource.rb
index e109ba7d1..666d26bcf 100755
--- a/test/rails/railsresource.rb
+++ b/test/rails/railsresource.rb
@@ -22,38 +22,33 @@ class TestRailsResource < Test::Unit::TestCase
host = Puppet::Rails::Host.new(:name => "myhost")
# Now build a resource
- 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
-
+ resource = host.rails_resources.build(
+ :title => "/tmp/to_resource", :restype => "file",
+ :exported => true
+ )
+
# Now add some params
{"owner" => "root", "mode" => "644"}.each do |param, 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
+ resource.rails_parameters.build(
+ :name => param, :value => value
+ )
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)