summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-28 15:20:52 -0600
committerLuke Kanies <luke@madstop.com>2007-11-28 15:20:52 -0600
commit11ae473e3852adcc382a3efea2329586d2e4bcb3 (patch)
tree7a7ff70f7d9f7bc9af0635c56690fb9fc810b9f5 /test
parent8127397e1efafc13975b79eabf7ce951c1e90114 (diff)
downloadpuppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.gz
puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.xz
puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.zip
Theoretically, this patch is to fix #917 (which it does), but
there were enough problems fixing it that I decided something more drastic needed to be done. This uses the new Puppet::ResourceReference class to canonize what a resource reference looks like and how to retrieve resources via their references. Specifically, it guarantees that resource types are always capitalized, even when they include '::' in them. While many files are modified in this commit, the majority of changes are quite small, and most of the changes are fixing the tests to use capitalized types. As we look at consolidating some of our resource types, we could consolidate the ResourceReference stuff at the same time, but at least the Puppet::Parser::ResourceReference class subclasses the main Puppet::ResourceReference class.
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/ast.rb2
-rwxr-xr-xtest/language/ast/definition.rb4
-rwxr-xr-xtest/language/ast/resource.rb8
-rwxr-xr-xtest/language/ast/resource_reference.rb12
-rwxr-xr-xtest/language/resource.rb18
-rwxr-xr-xtest/language/scope.rb2
-rwxr-xr-xtest/network/handler/resource.rb1
-rwxr-xr-xtest/other/dsl.rb1
-rwxr-xr-xtest/rails/ast.rb2
-rwxr-xr-xtest/rails/configuration.rb2
-rwxr-xr-xtest/rails/host.rb4
11 files changed, 29 insertions, 27 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb
index 141d27087..b31012d38 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -79,7 +79,7 @@ class TestAST < Test::Unit::TestCase
hash = nil
assert_nothing_raised do
- hash = scope.lookupdefaults("file")
+ hash = scope.lookupdefaults("File")
end
hash.each do |name, value|
diff --git a/test/language/ast/definition.rb b/test/language/ast/definition.rb
index b4d58a289..2a71aaa45 100755
--- a/test/language/ast/definition.rb
+++ b/test/language/ast/definition.rb
@@ -69,7 +69,7 @@ class TestASTDefinition < Test::Unit::TestCase
firstobj = config.findresource("File[/tmp/first]")
assert(firstobj, "Did not create /tmp/first obj")
- assert_equal("file", firstobj.type)
+ assert_equal("File", firstobj.type)
assert_equal("/tmp/first", firstobj.title)
assert_equal("nobody", firstobj[:owner])
assert_equal("755", firstobj[:mode])
@@ -99,7 +99,7 @@ class TestASTDefinition < Test::Unit::TestCase
secondobj = config.findresource("File[/tmp/second]")
assert(secondobj, "Did not create /tmp/second obj")
- assert_equal("file", secondobj.type)
+ assert_equal("File", secondobj.type)
assert_equal("/tmp/second", secondobj.title)
assert_equal("daemon", secondobj[:owner])
assert_equal("755", secondobj[:mode])
diff --git a/test/language/ast/resource.rb b/test/language/ast/resource.rb
index 49c64112d..c99d98eeb 100755
--- a/test/language/ast/resource.rb
+++ b/test/language/ast/resource.rb
@@ -36,19 +36,19 @@ class TestASTResource< Test::Unit::TestCase
title = "title"
# First try a qualified type
- assert_equal("one::two", newdef("two", title).evaluate(:scope => twoscope)[0].type,
+ assert_equal("One::Two", newdef("two", title).evaluate(:scope => twoscope)[0].type,
"Defined type was not made fully qualified")
# Then try a type that does not need to be qualified
- assert_equal("one", newdef("one", title).evaluate(:scope => twoscope)[0].type,
+ assert_equal("One", newdef("one", title).evaluate(:scope => twoscope)[0].type,
"Unqualified defined type was not handled correctly")
# Then an unqualified type from within the one namespace
- assert_equal("three", newdef("three", title).evaluate(:scope => twoscope)[0].type,
+ assert_equal("Three", newdef("three", title).evaluate(:scope => twoscope)[0].type,
"Defined type was not made fully qualified")
# Then a builtin type
- assert_equal("file", newdef("file", title).evaluate(:scope => twoscope)[0].type,
+ assert_equal("File", newdef("file", title).evaluate(:scope => twoscope)[0].type,
"Builtin type was not handled correctly")
# Now try a type that does not exist, which should throw an error.
diff --git a/test/language/ast/resource_reference.rb b/test/language/ast/resource_reference.rb
index 5a18d3f45..c9fde078f 100755
--- a/test/language/ast/resource_reference.rb
+++ b/test/language/ast/resource_reference.rb
@@ -26,7 +26,7 @@ class TestASTResourceReference < Test::Unit::TestCase
def test_evaluate
@parser.newdefine "one::two"
@parser.newdefine "one-two"
- [%w{file /tmp/yay}, %w{one::two three}, %w{one-two three}].each do |type, title|
+ [%w{File /tmp/yay}, %w{One::Two three}, %w{One-two three}].each do |type, title|
ref = newref(type, title)
evaled = nil
@@ -47,7 +47,7 @@ class TestASTResourceReference < Test::Unit::TestCase
evaled = ref.evaluate(:scope => @scope)
end
- assert_equal("class", evaled.type, "Did not set type to 'class'")
+ assert_equal("Class", evaled.type, "Did not set type to 'class'")
assert_equal("one", evaled.title, "Did not look up class corectly")
end
@@ -61,19 +61,19 @@ class TestASTResourceReference < Test::Unit::TestCase
title = "title"
# First try a qualified type
- assert_equal("one::two", newref("two", title).evaluate(:scope => twoscope).type,
+ assert_equal("One::Two", newref("two", title).evaluate(:scope => twoscope).type,
"Defined type was not made fully qualified")
# Then try a type that does not need to be qualified
- assert_equal("one", newref("one", title).evaluate(:scope => twoscope).type,
+ assert_equal("One", newref("one", title).evaluate(:scope => twoscope).type,
"Unqualified defined type was not handled correctly")
# Then an unqualified type from within the one namespace
- assert_equal("three", newref("three", title).evaluate(:scope => twoscope).type,
+ assert_equal("Three", newref("three", title).evaluate(:scope => twoscope).type,
"Defined type was not made fully qualified")
# Then a builtin type
- assert_equal("file", newref("file", title).evaluate(:scope => twoscope).type,
+ assert_equal("File", newref("file", title).evaluate(:scope => twoscope).type,
"Builtin type was not handled correctly")
# Now try a type that does not exist, which should throw an error.
diff --git a/test/language/resource.rb b/test/language/resource.rb
index 8ad3e62f1..d33e78a9c 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -41,7 +41,7 @@ class TestResource < PuppetTest::TestCase
end
ref = res.instance_variable_get("@ref")
- assert_equal("resource", ref.type, "did not set resource type")
+ assert_equal("Resource", ref.type, "did not set resource type")
assert_equal("testing", ref.title, "did not set resource title")
end
@@ -239,9 +239,9 @@ class TestResource < PuppetTest::TestCase
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")
+ 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.
@@ -255,7 +255,7 @@ class TestResource < PuppetTest::TestCase
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")
+ assert_equal("Mydefine", result.type, "did not set bucket type correctly")
end
def test_evaluate
@@ -312,7 +312,7 @@ class TestResource < PuppetTest::TestCase
res = Parser::Resource.new :type => "evaltest", :title => "yay",
:source => mock("source"), :scope => mkscope
- assert_equal("evaltest", res.type)
+ assert_equal("Evaltest", res.type)
assert_equal("yay", res.title)
assert_equal(false, res.builtin?)
end
@@ -332,7 +332,7 @@ class TestResource < PuppetTest::TestCase
end
assert_instance_of(Array, trans["require"])
- assert_equal(["file", "/tmp/ref1"], 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")
@@ -348,7 +348,7 @@ class TestResource < PuppetTest::TestCase
assert_instance_of(Array, trans["require"][0])
trans["require"].each do |val|
assert_instance_of(Array, val)
- assert_equal("file", val[0])
+ assert_equal("File", val[0])
assert(val[1] =~ /\/tmp\/ref[0-9]/,
"Was %s instead of the file name" % val[1])
end
@@ -487,7 +487,7 @@ class TestResource < PuppetTest::TestCase
# make sure we get each of them.
ptags = resource.tags
tags.each do |tag|
- assert(ptags.include?(tag), "missing #{tag}")
+ assert(ptags.include?(tag.downcase), "missing #{tag}")
end
end
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 990ca9694..ec11a864e 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -384,7 +384,7 @@ class TestScope < Test::Unit::TestCase
# And run the loop.
config.send(:evaluate_generators)
- %w{file}.each do |type|
+ %w{File}.each do |type|
objects = config.resources.find_all { |r| r.type == type and r.exported }
assert(!objects.empty?, "Did not get an exported %s" % type)
diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb
index b1f743082..00a88b57f 100755
--- a/test/network/handler/resource.rb
+++ b/test/network/handler/resource.rb
@@ -255,6 +255,7 @@ class TestResourceServer < Test::Unit::TestCase
bucket = Puppet::TransBucket.new
bucket.type = "file"
+ bucket.name = "test"
bucket.push filetrans
oldbucket = bucket.dup
diff --git a/test/other/dsl.rb b/test/other/dsl.rb
index 108c9fa31..b4dd0659b 100755
--- a/test/other/dsl.rb
+++ b/test/other/dsl.rb
@@ -11,6 +11,7 @@ class TestDSL < Test::Unit::TestCase
include Puppet::DSL
def teardown
+ super
Puppet::Aspect.clear
end
diff --git a/test/rails/ast.rb b/test/rails/ast.rb
index ac086fde1..e51fa6cf7 100755
--- a/test/rails/ast.rb
+++ b/test/rails/ast.rb
@@ -62,7 +62,7 @@ class TestRailsAST < PuppetTest::TestCase
assert_equal(1, retval.length, "Did not find resource with '#{string}'")
res = retval.shift
- assert_equal("file", res.restype)
+ assert_equal("File", res.restype)
assert_equal("/tmp/testing", res.title)
else
assert_equal(0, retval.length, "found a resource with '#{string}'")
diff --git a/test/rails/configuration.rb b/test/rails/configuration.rb
index ea66bc902..9e2ddfedd 100755
--- a/test/rails/configuration.rb
+++ b/test/rails/configuration.rb
@@ -36,7 +36,7 @@ class ConfigurationRailsTests < PuppetTest::TestCase
Puppet[:storeconfigs] = true
Puppet::Rails::Host.expects(:store).with do |node, resources|
- if res = resources.find { |r| r.type == "file" and r.title == "/tmp/yay" }
+ if res = resources.find { |r| r.type == "File" and r.title == "/tmp/yay" }
assert_equal("root", res["owner"], "Did not set default on resource")
true
else
diff --git a/test/rails/host.rb b/test/rails/host.rb
index dd1bb2a42..5853e8219 100755
--- a/test/rails/host.rb
+++ b/test/rails/host.rb
@@ -89,10 +89,10 @@ class TestRailsHost < PuppetTest::TestCase
end
assert(resource[:restype] != "", "Did not get a type from the resource")
case resource["restype"]
- when "file":
+ when "File":
assert_equal("user#{i}", resource.parameter("owner"),
"got no owner for %s" % resource.ref)
- when "exec":
+ when "Exec":
assert_equal("user#{i}", resource.parameter("user"),
"got no user for %s" % resource.ref)
else